-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
45 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import sslChecker from 'ssl-checker'; | ||
import Test, { TestParameters, Result } from '../Test'; | ||
import logger from '../logger'; | ||
|
||
class SSL extends Test { | ||
public name = 'SSL'; | ||
|
||
public async test({ url }: TestParameters): Promise<Result> { | ||
logger.info('Starting SSL test...'); | ||
const hostname = (new URL(url)).hostname; | ||
const sslDetails = await sslChecker(hostname); | ||
|
||
if (!sslDetails.valid) { | ||
return { | ||
status: 'ERROR', | ||
title: this.name, | ||
description: 'SSL certificate is not valid!', | ||
}; | ||
} | ||
|
||
if (sslDetails.daysRemaining <= 7) { | ||
return { | ||
status: 'WARNING', | ||
title: this.name, | ||
description: 'SSL certificate is valid for 7 or less days!', | ||
}; | ||
} | ||
|
||
return { | ||
status: 'SUCCESS', | ||
title: this.name, | ||
description: `SSL certificate is valid until ${sslDetails.validTo}.`, | ||
}; | ||
} | ||
} | ||
|
||
export default SSL; |
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