@@ -7,6 +7,7 @@ import TYPES from './di/types';
77import { AlertMode } from './Constants' ;
88import { ISslLabsService } from './interfaces/ISslLabsService' ;
99import { ITaskInput } from './interfaces/ITaskInput' ;
10+ import { ILogger } from './interfaces/ILogger' ;
1011
1112Task . setResourcePath ( path . join ( __dirname , 'task.json' ) ) ;
1213
@@ -16,22 +17,23 @@ async function run(): Promise<string> {
1617
1718 const taskInput : ITaskInput = container . get < ITaskInput > ( TYPES . ITaskInput ) ;
1819 const sslLabsService : ISslLabsService = container . get < ISslLabsService > ( TYPES . ISslLabsService ) ;
20+ const logger : ILogger = container . get < ILogger > ( TYPES . ILogger ) ;
1921
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 } ` ) ;
2325
24- const scanResult = await sslLabsService . executeSslTest ( ) ;
25- console . log ( 'Scan Completed...' ) ;
26+ const scanResult : any = await sslLabsService . executeSslTest ( ) ;
27+ logger . logConsole ( 'Scan Completed...' ) ;
2628
2729
2830 // Check for Verifications
2931 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 } ` ) ;
3133 const certGradeScore = await sslLabsService . getSslCertificateGrade ( scanResult ) ;
3234
3335 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' ) ;
3537 // If certificate grade threshold is passed
3638 switch ( taskInput . AlertMode ) {
3739 case AlertMode . BREAK_BUILD :
@@ -45,11 +47,11 @@ async function run(): Promise<string> {
4547 }
4648
4749 if ( taskInput . EnableExpirationAlert ) {
48- console . log ( 'Certificate expiration alerts Enabled.' ) ;
50+ logger . logConsole ( 'Certificate expiration alerts Enabled.' ) ;
4951 const daysTillExpire : number = await sslLabsService . timeTillCertificateExpiration ( scanResult ) ;
5052
5153 if ( daysTillExpire < taskInput . DaysBeforeExpiration ) {
52- console . log ( 'Minimum certifiate expire threshold exceeded. Executing Alert' ) ;
54+ logger . logConsole ( 'Minimum certifiate expire threshold exceeded. Executing Alert' ) ;
5355 switch ( taskInput . AlertMode ) {
5456 case AlertMode . BREAK_BUILD :
5557 throw new Error ( `SSL certificate is nearing expireation and will expire in ${ daysTillExpire } Days.` ) ;
0 commit comments