Skip to content

Commit

Permalink
add validation to port value parsing
Browse files Browse the repository at this point in the history
only port configurations that are valid (not isNaN) after parseInt
are considered to be used in port variable
  • Loading branch information
marcules committed Jan 8, 2022
1 parent 2c8d5d2 commit 0053a29
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ if (hostname) {
console.log("Custom hostname: " + hostname);
}

const port = parseInt(process.env.UPTIME_KUMA_PORT || process.env.PORT || args.port || 3001);
const port = [process.env.UPTIME_KUMA_PORT, process.env.PORT, args.port, 3001]
.map(portValue => parseInt(portValue))
.find(portValue => !isNaN(portValue));

// SSL
const sslKey = process.env.UPTIME_KUMA_SSL_KEY || process.env.SSL_KEY || args["ssl-key"] || undefined;
Expand Down

0 comments on commit 0053a29

Please sign in to comment.