From fbc79b85a3ad15b839f00f29c32867bd5a9061d1 Mon Sep 17 00:00:00 2001 From: Niel Markwick Date: Tue, 28 Nov 2023 17:16:59 +0100 Subject: [PATCH] Update Useragent string to correct format (#68) * Fix user agent string to be correct format * 2.3.1 --- README.md | 1 + cloudrun-malware-scanner/config.js | 3 ++- cloudrun-malware-scanner/gcs-proxy-server.js | 4 ++-- cloudrun-malware-scanner/package-lock.json | 4 ++-- cloudrun-malware-scanner/package.json | 2 +- cloudrun-malware-scanner/server.js | 3 ++- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 4be9054..c3c75ce 100755 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ Run and Eventarc. installs failed * 2023-11-22 v2.2.0 Add support for using environmental variables in the config.json file. * 2023-11-27 v2.3.0 Remove need for cloud-run-proxy, and update versions of packages. Fixes multiple CVEs. +* 2023-11-28 v2.3.1 Fix user agent string to use correct format. ## Upgrading from v1.x to v2.x diff --git a/cloudrun-malware-scanner/config.js b/cloudrun-malware-scanner/config.js index c1ef19a..8f16149 100644 --- a/cloudrun-malware-scanner/config.js +++ b/cloudrun-malware-scanner/config.js @@ -37,7 +37,8 @@ const pkgJson = require('./package.json'); */ const Config = null; -const storage = new Storage({userAgent: `${pkgJson.name}/${pkgJson.version}`}); +const storage = new Storage({userAgent: `cloud-solutions/${ + pkgJson.name}-usage-v${pkgJson.version}`}); /** * Read configuration from JSON configuration file, verify diff --git a/cloudrun-malware-scanner/gcs-proxy-server.js b/cloudrun-malware-scanner/gcs-proxy-server.js index 0c84607..7d55956 100644 --- a/cloudrun-malware-scanner/gcs-proxy-server.js +++ b/cloudrun-malware-scanner/gcs-proxy-server.js @@ -47,7 +47,7 @@ async function accessTokenRefresh() { client.credentials.expiry_date <= new Date().getTime() + TOKEN_REFRESH_THRESHOLD_MILLIS) { accessToken = await googleAuth.getAccessToken(); - logger.info(`Access token expires at ${ + logger.info(`Refreshed Access token; expires at ${ new Date(client.credentials.expiry_date).toISOString()}`); } const nextCheckDate = @@ -86,7 +86,7 @@ function handleProxyReq(proxyReq, req, res) { logger.info(`Proxying request for ${proxyReq.path} to GCS`); proxyReq.setHeader('Authorization', 'Bearer ' + accessToken); } else { - logger.error(`Denying Proxy request for ${proxyReq.path} to GCS`); + logger.error(`Denying Proxy request for ${proxyReq.path} to GCS - 403`); res.writeHead(403, { 'Content-Type': 'text/plain', }); diff --git a/cloudrun-malware-scanner/package-lock.json b/cloudrun-malware-scanner/package-lock.json index 88e33d9..cb69632 100644 --- a/cloudrun-malware-scanner/package-lock.json +++ b/cloudrun-malware-scanner/package-lock.json @@ -1,12 +1,12 @@ { "name": "gcs-malware-scanner", - "version": "2.3.0", + "version": "2.3.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "gcs-malware-scanner", - "version": "2.3.0", + "version": "2.3.1", "license": "Apache-2.0", "dependencies": { "@google-cloud/logging-bunyan": "^5.0.1", diff --git a/cloudrun-malware-scanner/package.json b/cloudrun-malware-scanner/package.json index 2c958fb..023098f 100644 --- a/cloudrun-malware-scanner/package.json +++ b/cloudrun-malware-scanner/package.json @@ -1,6 +1,6 @@ { "name": "gcs-malware-scanner", - "version": "2.3.0", + "version": "2.3.1", "description": "Service to scan GCS documents for the malware and move the analyzed documents to appropriate buckets", "main": "index.js", "scripts": { diff --git a/cloudrun-malware-scanner/server.js b/cloudrun-malware-scanner/server.js index ade93e5..018f66c 100644 --- a/cloudrun-malware-scanner/server.js +++ b/cloudrun-malware-scanner/server.js @@ -62,7 +62,8 @@ const BUCKET_CONFIG = { const app = express(); app.use(express.json()); const scanner = clamd.createScanner(CLAMD_HOST, CLAMD_PORT); -const storage = new Storage({userAgent: `${pkgJson.name}/${pkgJson.version}`}); +const storage = new Storage({userAgent: `cloud-solutions/${ + pkgJson.name}-usage-v${pkgJson.version}`}); const googleAuth = new GoogleAuth(); /**