Skip to content

Commit

Permalink
Fix linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nielm committed Nov 22, 2023
1 parent aeb00dd commit 1c6e6f7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions cloudrun-malware-scanner/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ const pkgJson = require('./package.json');
const loggingBunyan = new LoggingBunyan({
redirectToStdout: true,
projectId: process.env.PROJECT_ID,
logName: "malware-scanner",
useMessageField: false
logName: 'malware-scanner',
useMessageField: false,
});

exports.logger = bunyan.createLogger({
Expand Down
29 changes: 15 additions & 14 deletions cloudrun-malware-scanner/metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,21 @@ function writeScanCompletedMetric_(measure, sourceBucket, destinationBucket,

/**
* Writes metrics when a CVD Mirror Update occurs.
*
*
* @param {boolean} success
* @param {boolean} isUpdated
*/
function writeCvdMirrorUpdatedMetric(success, isUpdated) {
function writeCvdMirrorUpdatedMetric(success, isUpdated) {
const tags = new TagMap();
tags.set(TAGS.cloudRunRevision, {value: process.env.K_REVISION});
tags.set(TAGS.cvdUpdateStatus,
{value: (
tags.set(TAGS.cvdUpdateStatus,
{value: (
success ? (
isUpdated ? "SUCCESS_UPDATED" : "SUCCESS_NO_UPDATES" )
: "FAILURE" )});
isUpdated ? 'SUCCESS_UPDATED' : 'SUCCESS_NO_UPDATES' ) :
'FAILURE' )});
globalStats.record(
[{ measure: METRICS.cvdUpdates, value: 1}],
tags);
[{measure: METRICS.cvdUpdates, value: 1}],
tags);
}

/**
Expand All @@ -134,8 +134,8 @@ async function initMetrics(projectId) {
TAGS.clamVersion,
TAGS.cloudRunRevision,
TAGS.sourceBucket,
TAGS.destinationBucket
]
TAGS.destinationBucket,
];

METRICS.cleanFiles = globalStats.createMeasureInt64(
METRIC_TYPE_ROOT + 'clean-files', MeasureUnit.UNIT,
Expand Down Expand Up @@ -183,7 +183,8 @@ async function initMetrics(projectId) {
'The scan duration in milliseconds');
const scanDurationView = globalStats.createView(
METRICS.scanDuration.name, METRICS.scanDuration,
AggregationType.DISTRIBUTION, fileScanTags, 'Duration spent scanning files',
AggregationType.DISTRIBUTION, fileScanTags,
'Duration spent scanning files',
// Bucket Boundaries in ms
[
0,
Expand All @@ -203,12 +204,12 @@ async function initMetrics(projectId) {
globalStats.registerView(scanDurationView);

METRICS.cvdUpdates = globalStats.createMeasureInt64(
METRIC_TYPE_ROOT + 'cvd-mirror-updates', MeasureUnit.UNIT,
'Number of CVD mirror Update Checks performed');
METRIC_TYPE_ROOT + 'cvd-mirror-updates', MeasureUnit.UNIT,
'Number of CVD mirror Update Checks performed');

const cvdUpdatesView = globalStats.createView(
METRICS.cvdUpdates.name, METRICS.cvdUpdates,
AggregationType.COUNT,
AggregationType.COUNT,
[TAGS.cloudRunRevision, TAGS.cvdUpdateStatus],
'Number of CVD mirror update checks performed with their status');
globalStats.registerView(cvdUpdatesView);
Expand Down
7 changes: 3 additions & 4 deletions cloudrun-malware-scanner/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
const clamd = require('clamdjs');
const express = require('express');
const {Storage} = require('@google-cloud/storage');
const {ApiError} = require('@google-cloud/common');
const {GoogleAuth} = require('google-auth-library');
const {logger} = require('./logger.js');
const pkgJson = require('./package.json');
Expand Down Expand Up @@ -327,7 +326,7 @@ async function moveProcessedFile(filename, isClean, config) {
*/
async function readAndVerifyConfig(configFile) {
logger.info(`Using configuration file: ${configFile}`);

try {
const config = require(configFile);
delete config.comments;
Expand Down Expand Up @@ -443,10 +442,10 @@ async function run() {
await metrics.init(projectId);

let configFile;
if(process.argv.length >= 3) {
if (process.argv.length >= 3) {
configFile = process.argv[2];
} else {
configFile = "./config.json"
configFile = './config.json';
}
await readAndVerifyConfig(configFile);
process.exit(1);
Expand Down

0 comments on commit 1c6e6f7

Please sign in to comment.