@@ -12,11 +12,18 @@ import { SecurityDataController } from './security-data.controller';
1212
1313import pino from 'pino' ;
1414import { getRootLogger } from '../../../libs/logging/src' ;
15- import { logCount } from " ../../../libs/logging/src/metric-utils" ;
15+ import { logCount } from ' ../../../libs/logging/src/metric-utils' ;
1616
17- function createCommandLogger ( commandName : string , options = undefined ) : pino . Logger {
17+ function createCommandLogger (
18+ commandName : string ,
19+ options = undefined ,
20+ ) : pino . Logger {
1821 const appLogger = getRootLogger ( ) ;
19- return appLogger . child ( { cliCommand : commandName , sseContext : 'Cli.Main' , cliOptions : options } ) ;
22+ return appLogger . child ( {
23+ cliCommand : commandName ,
24+ sseContext : 'Cli.Main' ,
25+ cliOptions : options ,
26+ } ) ;
2027}
2128
2229async function bootstrap ( ) {
@@ -32,19 +39,24 @@ function printMemoryUsage(logger: pino.Logger) {
3239 const used = process . memoryUsage ( ) ;
3340 for ( const key in used ) {
3441 const valueMb = Math . round ( ( used [ key ] / 1024 / 1024 ) * 100 ) / 100 ;
35- logCount ( logger , {
42+ logCount (
43+ logger ,
44+ {
3645 metricUnit : 'megabytes' ,
3746 } ,
3847 `scanner.core.memory.used.${ key } .mb` ,
3948 `Memory used: ${ key } : ${ valueMb } MB` ,
40- valueMb
49+ valueMb ,
4150 ) ;
4251 }
4352}
4453
4554async function ingest ( cmdObj ) {
4655 const nestApp = await bootstrap ( ) ;
47- const logger = createCommandLogger ( 'ingest' , { limit : cmdObj . limit , federalSubdomainsUrl : cmdObj . federalSubdomainsUrl } ) ;
56+ const logger = createCommandLogger ( 'ingest' , {
57+ limit : cmdObj . limit ,
58+ federalSubdomainsUrl : cmdObj . federalSubdomainsUrl ,
59+ } ) ;
4860 const controller = nestApp . get ( IngestController ) ;
4961 logger . info ( 'ingesting target urls' ) ;
5062
@@ -82,8 +94,14 @@ async function checkQueueStatus() {
8294 logger . info ( 'checking queue status' ) ;
8395
8496 const queueStatus = await controller . getQueueStatus ( ) ;
85- logger . info ( { jobsRemaining : queueStatus . count } , `${ queueStatus . count } jobs remaining in queue` ) ;
86- logger . info ( { activeJobs : queueStatus . activeCount } , `${ queueStatus . activeCount } active jobs in queue` ) ;
97+ logger . info (
98+ { jobsRemaining : queueStatus . count } ,
99+ `${ queueStatus . count } jobs remaining in queue` ,
100+ ) ;
101+ logger . info (
102+ { activeJobs : queueStatus . activeCount } ,
103+ `${ queueStatus . activeCount } active jobs in queue` ,
104+ ) ;
87105 printMemoryUsage ( logger ) ;
88106 await nestApp . close ( ) ;
89107}
@@ -101,7 +119,9 @@ async function enqueueSite(cmdObj) {
101119
102120async function enqueueLimitedScans ( cmdObj ) {
103121 const nestApp = await bootstrap ( ) ;
104- const logger = createCommandLogger ( 'enqueue-limited-scans' , { limit : cmdObj . limit } ) ;
122+ const logger = createCommandLogger ( 'enqueue-limited-scans' , {
123+ limit : cmdObj . limit ,
124+ } ) ;
105125 const controller = nestApp . get ( QueueController ) ;
106126 logger . info ( 'enqueueing limited scan jobs' ) ;
107127
@@ -110,17 +130,6 @@ async function enqueueLimitedScans(cmdObj) {
110130 await nestApp . close ( ) ;
111131}
112132
113- async function createSnapshot ( ) {
114- const nestApp = await bootstrap ( ) ;
115- const logger = createCommandLogger ( 'create-snapshot' ) ;
116- const controller = nestApp . get ( SnapshotController ) ;
117- logger . info ( 'creating snapshot' ) ;
118-
119- await controller . weeklySnapshot ( ) ;
120- printMemoryUsage ( logger ) ;
121- await nestApp . close ( ) ;
122- }
123-
124133async function createDailySnapshot ( ) {
125134 const nestApp = await bootstrap ( ) ;
126135 const logger = createCommandLogger ( 'create-daily-snapshot' ) ;
@@ -145,11 +154,15 @@ async function createAccessibilityResultsSnapshot() {
145154
146155async function scanSite ( cmdObj ) {
147156 const nestApp = await bootstrap ( ) ;
148- const logger = createCommandLogger ( 'scan-site' , { url : cmdObj . url , page : cmdObj . page , scan : cmdObj . scan } ) ;
157+ const logger = createCommandLogger ( 'scan-site' , {
158+ url : cmdObj . url ,
159+ page : cmdObj . page ,
160+ scan : cmdObj . scan ,
161+ } ) ;
149162 const controller = nestApp . get ( ScanController ) ;
150163
151164 logger . info (
152- `Scanning site: ${ cmdObj . url } , page: ${ cmdObj . page ?? 'ALL' } , scan: ${ cmdObj . scan ?? 'ALL' } `
165+ `Scanning site: ${ cmdObj . url } , page: ${ cmdObj . page ?? 'ALL' } , scan: ${ cmdObj . scan ?? 'ALL' } ` ,
153166 ) ;
154167
155168 await controller . scanSite ( cmdObj . url , cmdObj . page , cmdObj . scan ) ;
@@ -232,10 +245,7 @@ async function main() {
232245 . description (
233246 'enqueue-site add 1 site from the Website database table to the redis queue' ,
234247 )
235- . option (
236- '--url <string>' ,
237- 'queue up one specific site by URL'
238- )
248+ . option ( '--url <string>' , 'queue up one specific site by URL' )
239249 . action ( enqueueSite ) ;
240250
241251 // queue-status
@@ -245,7 +255,7 @@ async function main() {
245255 'queue-status retrieves the active and remaining jobs in the redis queue' ,
246256 )
247257 . action ( checkQueueStatus ) ;
248-
258+
249259 // queue-limited-scans
250260 program
251261 . command ( 'enqueue-limited-scans' )
@@ -259,14 +269,6 @@ async function main() {
259269 )
260270 . action ( ( cmdObj ) => enqueueLimitedScans ( cmdObj ) ) ;
261271
262- // create-snapshot
263- program
264- . command ( 'create-snapshot' )
265- . description (
266- 'create-snapshot writes a CSV and JSON of the current scans to S3' ,
267- )
268- . action ( createSnapshot ) ;
269-
270272 // create-daily-snapshot
271273 program
272274 . command ( 'create-daily-snapshot' )
@@ -287,7 +289,7 @@ async function main() {
287289 program
288290 . command ( 'scan-site' )
289291 . description (
290- 'scan-site scans a given URL, which MUST exist in the website table'
292+ 'scan-site scans a given URL, which MUST exist in the website table' ,
291293 )
292294 . option ( '--url <string>' , 'URL to scan' )
293295 . option ( '--page <string>' , 'Page to scan (optional)' )
@@ -321,4 +323,4 @@ async function main() {
321323 await program . parseAsync ( process . argv ) ;
322324}
323325
324- main ( ) ;
326+ main ( ) ;
0 commit comments