Skip to content

Commit

Permalink
Added plugin name and version number in API user agent header (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
RahulPidde23 authored Nov 28, 2024
1 parent cb56f81 commit 8b3e611
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
16 changes: 16 additions & 0 deletions CxScan/CxScanV20/model/CxPluginDetails.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import * as fs from 'fs';
import * as path from 'path';

export class CxPluginDetails {

static getPluginVersion(): string | undefined {
try {
const packageJson = fs.readFileSync(path.resolve(__dirname, '../../package.json'), 'utf8');
const packageData = JSON.parse(packageJson);
return packageData.version;
} catch (error) {
console.error('Error reading package.json:', error);
return undefined;
}
}
}
2 changes: 1 addition & 1 deletion CxScan/CxScanV20/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"author": "MajdM",
"license": "SEE LICENSE IN checkmarx-license-terms.md",
"dependencies": {
"@checkmarx/cx-common-js-client": "0.1.87",
"@checkmarx/cx-common-js-client": "0.1.88",
"degenerator": "5.0.1",
"azure-pipelines-task-lib": "^4.17.3",
"cookiejar": "2.1.4",
Expand Down
5 changes: 4 additions & 1 deletion CxScan/CxScanV20/services/configReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import * as url from "url";
import { homedir } from 'os';
import path = require('path');
import { config } from 'process';
import { CxPluginDetails } from '../model/CxPluginDetails';
const os = require("os");
const fs = require('fs');

Expand Down Expand Up @@ -443,7 +444,9 @@ export class ConfigReader {
cxOrigin: jobOrigin,
cxOriginUrl: cxOriginUrl,
projectName: taskLib.getInput('projectName', false) || '',
proxyConfig: proxyResult
proxyConfig: proxyResult,
version: CxPluginDetails.getPluginVersion(),
originName: "VSTS"
};
this.format(result);
this.formatSCA(result);
Expand Down

0 comments on commit 8b3e611

Please sign in to comment.