Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set eu option #2

Merged
merged 2 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ inputs:
description: 'The number of days which the sandbox had no activity'
required: false
default: "0"
european-region:
description: 'For platforms using .eu'
required: false
default: "false"
runs:
using: 'node12'
main: 'dist/index.js'
Expand Down
11 changes: 9 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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':
Expand Down
3 changes: 2 additions & 1 deletion src/Options.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ export interface Options {
sandboxName: string,
cleanAmount: number,
deleteOnPromote: boolean,
cleanModifiedBefore: number
cleanModifiedBefore: number,
europeanRegion: boolean
}
3 changes: 2 additions & 1 deletion src/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const preFix = "VERACODE-HMAC-SHA-256";
const verStr = "vcode_request_version_1";
const alg = 'sha256';

const host = "api.²";
const host = "api.veracode.com";

const hmac256 = (data:BinaryLike, key: BinaryLike, format?: BinaryToTextEncoding ) => {
var hash = createHmac(alg, key).update(data);
Expand Down