@@ -7,6 +7,7 @@ import TYPES from './di/types';
7
7
import { AlertMode } from './Constants' ;
8
8
import { ISslLabsService } from './interfaces/ISslLabsService' ;
9
9
import { ITaskInput } from './interfaces/ITaskInput' ;
10
+ import { ILogger } from './interfaces/ILogger' ;
10
11
11
12
Task . setResourcePath ( path . join ( __dirname , 'task.json' ) ) ;
12
13
@@ -16,22 +17,23 @@ async function run(): Promise<string> {
16
17
17
18
const taskInput : ITaskInput = container . get < ITaskInput > ( TYPES . ITaskInput ) ;
18
19
const sslLabsService : ISslLabsService = container . get < ISslLabsService > ( TYPES . ISslLabsService ) ;
20
+ const logger : ILogger = container . get < ILogger > ( TYPES . ILogger ) ;
19
21
20
- Task . debug ( taskInput . toJSON ( ) ) ;
21
- Task . debug ( 'Executing SSL Labs Scan with the given inputs' ) ;
22
- console . log ( `Starting SSL Labs Scan for the hostname: ${ taskInput . Hostname } ` ) ;
22
+ logger . logDebug ( taskInput . toJSON ( ) ) ;
23
+ logger . logDebug ( 'Executing SSL Labs Scan with the given inputs' ) ;
24
+ logger . logConsole ( `Starting SSL Labs Scan for the hostname: ${ taskInput . Hostname } ` ) ;
23
25
24
- const scanResult = await sslLabsService . executeSslTest ( ) ;
25
- console . log ( 'Scan Completed...' ) ;
26
+ const scanResult : any = await sslLabsService . executeSslTest ( ) ;
27
+ logger . logConsole ( 'Scan Completed...' ) ;
26
28
27
29
28
30
// Check for Verifications
29
31
if ( taskInput . EnableVerification ) {
30
- console . log ( `Verifications are Enabled with the Alert Mode: ${ taskInput . AlertMode } ` ) ;
32
+ logger . logConsole ( `Verifications are Enabled with the Alert Mode: ${ taskInput . AlertMode } ` ) ;
31
33
const certGradeScore = await sslLabsService . getSslCertificateGrade ( scanResult ) ;
32
34
33
35
if ( Number ( taskInput . MinimumCertGrade ) > certGradeScore ) {
34
- console . log ( 'Minimum certifiate grade threshold exceeded. Executing Alert' ) ;
36
+ logger . logConsole ( 'Minimum certifiate grade threshold exceeded. Executing Alert' ) ;
35
37
// If certificate grade threshold is passed
36
38
switch ( taskInput . AlertMode ) {
37
39
case AlertMode . BREAK_BUILD :
@@ -45,11 +47,11 @@ async function run(): Promise<string> {
45
47
}
46
48
47
49
if ( taskInput . EnableExpirationAlert ) {
48
- console . log ( 'Certificate expiration alerts Enabled.' ) ;
50
+ logger . logConsole ( 'Certificate expiration alerts Enabled.' ) ;
49
51
const daysTillExpire : number = await sslLabsService . timeTillCertificateExpiration ( scanResult ) ;
50
52
51
53
if ( daysTillExpire < taskInput . DaysBeforeExpiration ) {
52
- console . log ( 'Minimum certifiate expire threshold exceeded. Executing Alert' ) ;
54
+ logger . logConsole ( 'Minimum certifiate expire threshold exceeded. Executing Alert' ) ;
53
55
switch ( taskInput . AlertMode ) {
54
56
case AlertMode . BREAK_BUILD :
55
57
throw new Error ( `SSL certificate is nearing expireation and will expire in ${ daysTillExpire } Days.` ) ;
0 commit comments