-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix issue with invalid domain * fix test * fix fmt * add build * fix format * fix format * fixes etc * Try the #24 error * fix ci * revert 1 off test * update package & rebuild
- Loading branch information
Zac Rosenbauer
authored
May 6, 2021
1 parent
2d3c82a
commit ba35b85
Showing
12 changed files
with
314 additions
and
276 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -292,28 +292,38 @@ async function run() { | |
const alertMethod = core.getInput('alert_method'); | ||
const alertToken = core.getInput('alert_token'); | ||
const isAlertEnabled = !!alertMethod; | ||
const result = await tls.getTLSInfo(domain); | ||
let errorMessage = ''; | ||
let result; | ||
try { | ||
result = await tls.getTLSInfo(domain); | ||
} | ||
catch (err) { | ||
errorMessage = err.message || `Unable to get TLS Info for domain ${domain}`; | ||
} | ||
if (isAlertEnabled) { | ||
const validationResults = validate_1.validate({ | ||
expirationDays: Number(expirationDays), | ||
approvedProtocols: getApprovedProtocols(approvedProtocols), | ||
tlsInfo: result | ||
}); | ||
if (validationResults.errorMessage) { | ||
errorMessage = validationResults.errorMessage; | ||
if (result) { | ||
const validationResults = validate_1.validate({ | ||
expirationDays: Number(expirationDays), | ||
approvedProtocols: getApprovedProtocols(approvedProtocols), | ||
tlsInfo: result | ||
}); | ||
if (validationResults.errorMessage) { | ||
errorMessage = validationResults.errorMessage; | ||
} | ||
} | ||
if (errorMessage) { | ||
await alerts.send(alertMethod, alertToken, { | ||
domain, | ||
validTo: result.validTo.toISOString(), | ||
validFrom: result.validFrom.toISOString(), | ||
protocol: result.protocol, | ||
validTo: (result === null || result === void 0 ? void 0 : result.validTo.toISOString()) || 'unknown', | ||
validFrom: (result === null || result === void 0 ? void 0 : result.validFrom.toISOString()) || 'unknown', | ||
protocol: ((result === null || result === void 0 ? void 0 : result.protocol) || 'unknown'), | ||
errorMessage | ||
}); | ||
} | ||
} | ||
core.setOutput('protocol', result.protocol); | ||
core.setOutput('valid_to', result.validTo); | ||
core.setOutput('valid_from', result.validFrom); | ||
core.setOutput('protocol', (result === null || result === void 0 ? void 0 : result.protocol) || 'unknown'); | ||
core.setOutput('valid_to', (result === null || result === void 0 ? void 0 : result.validTo) || 'unknown'); | ||
core.setOutput('valid_from', (result === null || result === void 0 ? void 0 : result.validFrom) || 'unknown'); | ||
core.setOutput('error_message', errorMessage); | ||
} | ||
run(); | ||
|
@@ -517,6 +527,7 @@ exports.getInput = getInput; | |
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
function setOutput(name, value) { | ||
process.stdout.write(os.EOL); | ||
command_1.issueCommand('set-output', { name }, value); | ||
} | ||
exports.setOutput = setOutput; | ||
|
@@ -3843,8 +3854,9 @@ var assert = __nccwpck_require__(2357); | |
var debug = __nccwpck_require__(1133); | ||
|
||
// Create handlers that pass events from native requests | ||
var events = ["abort", "aborted", "connect", "error", "socket", "timeout"]; | ||
var eventHandlers = Object.create(null); | ||
["abort", "aborted", "connect", "error", "socket", "timeout"].forEach(function (event) { | ||
events.forEach(function (event) { | ||
eventHandlers[event] = function (arg1, arg2, arg3) { | ||
this._redirectable.emit(event, arg1, arg2, arg3); | ||
}; | ||
|
@@ -3899,9 +3911,7 @@ RedirectableRequest.prototype = Object.create(Writable.prototype); | |
|
||
RedirectableRequest.prototype.abort = function () { | ||
// Abort the internal request | ||
this._currentRequest.removeAllListeners(); | ||
this._currentRequest.on("error", noop); | ||
this._currentRequest.abort(); | ||
abortRequest(this._currentRequest); | ||
|
||
// Abort this request | ||
this.emit("abort"); | ||
|
@@ -3992,15 +4002,22 @@ RedirectableRequest.prototype.setTimeout = function (msecs, callback) { | |
this.on("timeout", callback); | ||
} | ||
|
||
function destroyOnTimeout(socket) { | ||
socket.setTimeout(msecs); | ||
socket.removeListener("timeout", socket.destroy); | ||
socket.addListener("timeout", socket.destroy); | ||
} | ||
|
||
// Sets up a timer to trigger a timeout event | ||
function startTimer() { | ||
function startTimer(socket) { | ||
if (self._timeout) { | ||
clearTimeout(self._timeout); | ||
} | ||
self._timeout = setTimeout(function () { | ||
self.emit("timeout"); | ||
clearTimer(); | ||
}, msecs); | ||
destroyOnTimeout(socket); | ||
} | ||
|
||
// Prevent a timeout from triggering | ||
|
@@ -4016,12 +4033,13 @@ RedirectableRequest.prototype.setTimeout = function (msecs, callback) { | |
|
||
// Start the timer when the socket is opened | ||
if (this.socket) { | ||
startTimer(); | ||
startTimer(this.socket); | ||
} | ||
else { | ||
this._currentRequest.once("socket", startTimer); | ||
} | ||
|
||
this.on("socket", destroyOnTimeout); | ||
this.once("response", clearTimer); | ||
this.once("error", clearTimer); | ||
|
||
|
@@ -4100,11 +4118,8 @@ RedirectableRequest.prototype._performRequest = function () { | |
|
||
// Set up event handlers | ||
request._redirectable = this; | ||
for (var event in eventHandlers) { | ||
/* istanbul ignore else */ | ||
if (event) { | ||
request.on(event, eventHandlers[event]); | ||
} | ||
for (var e = 0; e < events.length; e++) { | ||
request.on(events[e], eventHandlers[events[e]]); | ||
} | ||
|
||
// End a redirected request | ||
|
@@ -4162,9 +4177,7 @@ RedirectableRequest.prototype._processResponse = function (response) { | |
if (location && this._options.followRedirects !== false && | ||
statusCode >= 300 && statusCode < 400) { | ||
// Abort the current request | ||
this._currentRequest.removeAllListeners(); | ||
this._currentRequest.on("error", noop); | ||
this._currentRequest.abort(); | ||
abortRequest(this._currentRequest); | ||
// Discard the remainder of the response to avoid waiting for data | ||
response.destroy(); | ||
|
||
|
@@ -4356,6 +4369,14 @@ function createErrorType(code, defaultMessage) { | |
return CustomError; | ||
} | ||
|
||
function abortRequest(request) { | ||
for (var e = 0; e < events.length; e++) { | ||
request.removeListener(events[e], eventHandlers[events[e]]); | ||
} | ||
request.on("error", noop); | ||
request.abort(); | ||
} | ||
|
||
// Exports | ||
module.exports = wrap({ http: http, https: https }); | ||
module.exports.wrap = wrap; | ||
|
@@ -21912,7 +21933,7 @@ module.exports = { | |
/***/ ((module) => { | ||
|
||
"use strict"; | ||
module.exports = JSON.parse('{"name":"action-tls-monitor","version":"1.0.0","description":"Monitor SSL/TLS certificates for your domains.","main":"dist/main.js","repository":"[email protected]:bluenovaio/action-tls-monitor.git","author":"@bluenovaio","license":"MIT","private":false,"scripts":{"build":"tsc","format":"prettier --write **/*.ts","format-check":"prettier --check **/*.ts","lint":"eslint src/**/*.ts","package":"ncc build --source-map --license licenses.txt","test":"jest"},"dependencies":{"@actions/core":"^1.2.7","@slack/webhook":"^6.0.0","gaxios":"^4.2.0","lodash":"^4.17.21"},"devDependencies":{"@jest/types":"^26.6.2","@types/jest":"^26.0.20","@types/lodash":"^4.14.168","@types/node":"^15.0.1","@typescript-eslint/eslint-plugin":"^4.22.0","@typescript-eslint/parser":"^4.22.0","@vercel/ncc":"0.28.4","eslint":"^7.25.0","eslint-config-semistandard":"^15.0.1","eslint-config-standard":"^16.0.2","eslint-plugin-import":"^2.22.1","eslint-plugin-node":"^11.1.0","eslint-plugin-promise":"5.1.0","eslint-plugin-standard":"^5.0.0","jest":"^26.6.3","prettier":"^2.2.1","ts-jest":"^26.5.5","ts-node":"^9.1.1","typescript":"^4.2.3","webpack":"^5.36.2"}}'); | ||
module.exports = JSON.parse('{"name":"action-tls-monitor","version":"1.0.0","description":"Monitor SSL/TLS certificates for your domains.","main":"dist/main.js","repository":"[email protected]:bluenovaio/action-tls-monitor.git","author":"@bluenovaio","license":"MIT","private":false,"scripts":{"build":"tsc","format":"prettier --write **/*.ts","format-check":"prettier --check **/*.ts","lint":"eslint src/**/*.ts","package":"ncc build --source-map --license licenses.txt","test":"jest"},"dependencies":{"@actions/core":"^1.2.7","@slack/webhook":"^6.0.0","gaxios":"^4.2.0","lodash":"^4.17.21"},"devDependencies":{"@jest/types":"^26.6.2","@types/jest":"^26.0.20","@types/lodash":"^4.14.168","@types/node":"^15.0.1","@typescript-eslint/eslint-plugin":"^4.22.0","@typescript-eslint/parser":"^4.22.0","@vercel/ncc":"0.28.5","eslint":"^7.25.0","eslint-config-semistandard":"^15.0.1","eslint-config-standard":"^16.0.2","eslint-plugin-import":"^2.22.1","eslint-plugin-node":"^11.1.0","eslint-plugin-promise":"5.1.0","eslint-plugin-standard":"^5.0.0","jest":"^26.6.3","prettier":"^2.2.1","ts-jest":"^26.5.5","ts-node":"^9.1.1","typescript":"^4.2.3","webpack":"^5.36.2"}}'); | ||
|
||
/***/ }), | ||
|
||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
import { Protocol } from '../tls'; | ||
export interface AlertInput { | ||
domain: string; | ||
validTo: string; | ||
validFrom: string; | ||
protocol: string; | ||
protocol: Protocol; | ||
errorMessage: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import { Protocol } from '../tls'; | ||
|
||
export interface AlertInput { | ||
domain: string; | ||
validTo: string; | ||
validFrom: string; | ||
protocol: string; | ||
protocol: Protocol; | ||
errorMessage: string; | ||
} |
Oops, something went wrong.