From 4ad088b330b28bb2f2b27c3116c04f8aa4c5105d Mon Sep 17 00:00:00 2001 From: schapron Date: Tue, 18 Jul 2023 19:37:52 +0200 Subject: [PATCH 1/2] feat(eu): manage eu platforms from action params --- action.yml | 4 ++++ dist/index.js | 11 +++++++++-- src/Options.d.ts | 3 ++- src/action.ts | 3 ++- src/auth.ts | 2 +- 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index b31b4c4..53a5109 100644 --- a/action.yml +++ b/action.yml @@ -26,6 +26,10 @@ inputs: description: 'The number of days which the sandbox had no activity' required: false default: "0" + european-region: + description: 'For platform using .eu' + required: false + default: false runs: using: 'node12' main: 'dist/index.js' diff --git a/dist/index.js b/dist/index.js index f3df04e..02f1450 100755 --- a/dist/index.js +++ b/dist/index.js @@ -4622,7 +4622,8 @@ try { sandboxName: core.getInput('sandbox-name', { trimWhitespace: true }), cleanAmount: Number.parseInt(core.getInput('clean-amount')), deleteOnPromote: core.getBooleanInput('delete-on-promote') || false, - cleanModifiedBefore: parseInt(core.getInput('clean-modified-before', { trimWhitespace: true }) || '0') + cleanModifiedBefore: parseInt(core.getInput('clean-modified-before', { trimWhitespace: true }) || '0'), + europeanRegion: core.getBooleanInput('european-region') || false }; if (o.activity !== 'clean' && o.sandboxName.length === 0) { let message = `Need Sandbox name to execute action: ${o.activity}`; @@ -4873,10 +4874,15 @@ exports.SandboxAPIProcessor = SandboxAPIProcessor; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.generateHeader = exports.getHost = void 0; const crypto_1 = __nccwpck_require__(6417); +const core = __importStar(__nccwpck_require__(2186)); const preFix = "VERACODE-HMAC-SHA-256"; const verStr = "vcode_request_version_1"; const alg = 'sha256'; -const host = "api.veracode.eu"; +if (core.getBooleanInput('european-region') == true) { + const host = "api.veracode.eu"; +} else { + const host = "api.veracode.com"; +} const hmac256 = (data, key, format) => { var hash = (0, crypto_1.createHmac)(alg, key).update(data); // no format = Buffer / byte array @@ -4942,6 +4948,7 @@ function run(opt, msgFunc) { const sandboxName = opt.sandboxName; const amount = opt.cleanAmount; const modifiedBefore = new Date(); + const euRegion = opt.europeanRegion; modifiedBefore.setDate(modifiedBefore.getDate() - opt.cleanModifiedBefore); switch (action) { case 'clean': diff --git a/src/Options.d.ts b/src/Options.d.ts index c6ee359..092972c 100644 --- a/src/Options.d.ts +++ b/src/Options.d.ts @@ -4,5 +4,6 @@ export interface Options { sandboxName: string, cleanAmount: number, deleteOnPromote: boolean, - cleanModifiedBefore: number + cleanModifiedBefore: number, + europeanRegion: boolean } \ No newline at end of file diff --git a/src/action.ts b/src/action.ts index 9cf21da..177103c 100644 --- a/src/action.ts +++ b/src/action.ts @@ -11,7 +11,8 @@ try { sandboxName: core.getInput('sandbox-name',{trimWhitespace:true}), cleanAmount: Number.parseInt(core.getInput('clean-amount')), deleteOnPromote: core.getBooleanInput('delete-on-promote') || false, - cleanModifiedBefore: parseInt(core.getInput('clean-modified-before',{trimWhitespace:true}) || '0') + cleanModifiedBefore: parseInt(core.getInput('clean-modified-before',{trimWhitespace:true}) || '0'), + europeanRegion: core.getBooleanInput('european-region') || false }; if (o.activity !== 'clean' && o.sandboxName.length===0) { diff --git a/src/auth.ts b/src/auth.ts index e274578..829eb6f 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -1,10 +1,10 @@ import {BinaryLike, BinaryToTextEncoding, createHmac,randomBytes} from 'crypto'; +const core = __importStar(__nccwpck_require__(2186)); const preFix = "VERACODE-HMAC-SHA-256"; const verStr = "vcode_request_version_1"; const alg = 'sha256'; -const host = "api.²"; const hmac256 = (data:BinaryLike, key: BinaryLike, format?: BinaryToTextEncoding ) => { var hash = createHmac(alg, key).update(data); From b8c12b91d590c0b5b839eb750482091f72ef47d4 Mon Sep 17 00:00:00 2001 From: schapron Date: Tue, 18 Jul 2023 19:52:32 +0200 Subject: [PATCH 2/2] wip --- action.yml | 4 ++-- src/auth.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index 53a5109..9ac2a99 100644 --- a/action.yml +++ b/action.yml @@ -27,9 +27,9 @@ inputs: required: false default: "0" european-region: - description: 'For platform using .eu' + description: 'For platforms using .eu' required: false - default: false + default: "false" runs: using: 'node12' main: 'dist/index.js' diff --git a/src/auth.ts b/src/auth.ts index 829eb6f..e4055a8 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -1,10 +1,10 @@ import {BinaryLike, BinaryToTextEncoding, createHmac,randomBytes} from 'crypto'; -const core = __importStar(__nccwpck_require__(2186)); const preFix = "VERACODE-HMAC-SHA-256"; const verStr = "vcode_request_version_1"; const alg = 'sha256'; +const host = "api.veracode.com"; const hmac256 = (data:BinaryLike, key: BinaryLike, format?: BinaryToTextEncoding ) => { var hash = createHmac(alg, key).update(data);