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

feat: add owasp zap scan task type migration (#4260) #4280

Merged
merged 1 commit into from
Oct 25, 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
3 changes: 3 additions & 0 deletions api/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ function defaultContext(req, res) {
};
}

const DEFAULT_BUILD_TASK_PARAMS = "-p '{ \"STATUS_CALLBACK\": \"{{job.data.STATUS_CALLBACK}}\", \"TASK_ID\": {{job.data.TASK_ID}}, \"AWS_DEFAULT_REGION\": \"{{job.data.AWS_DEFAULT_REGION}}\", \"AWS_ACCESS_KEY_ID\": \"{{job.data.AWS_ACCESS_KEY_ID}}\", \"AWS_SECRET_ACCESS_KEY\": \"{{job.data.AWS_SECRET_ACCESS_KEY}}\", \"BUCKET\": \"{{job.data.BUCKET}}\" }'";

module.exports = {
buildEnum,
generateS3ServiceName,
Expand All @@ -288,4 +290,5 @@ module.exports = {
wrapHandler,
wrapHandlers,
defaultContext,
DEFAULT_BUILD_TASK_PARAMS,
};
1 change: 1 addition & 0 deletions ci/pipeline-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ jobs:
image: cf-image
params:
<<: *env-cf
APP_ENV: ((deploy-env))
CF_APP_NAME: pages-((deploy-env))
CF_TASK_NAME: run-migrations
CF_TASK_COMMAND: 'yarn run migrate:up'
Expand Down
1 change: 1 addition & 0 deletions ci/pipeline-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ jobs:
image: cf-image
params:
<<: *env-cf
APP_ENV: ((deploy-env))
CF_APP_NAME: pages-((deploy-env))
CF_TASK_NAME: run-migrations
CF_TASK_COMMAND: 'yarn run migrate:up'
Expand Down
1 change: 1 addition & 0 deletions ci/pipeline-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ jobs:
image: cf-image
params:
<<: *env-cf
APP_ENV: ((deploy-env))
CF_APP_NAME: pages-((deploy-env))
CF_TASK_NAME: run-migrations
CF_TASK_COMMAND: 'yarn run migrate:up'
Expand Down
32 changes: 32 additions & 0 deletions migrations/20231025141411-btt-owasp-zap-scan.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const { DEFAULT_BUILD_TASK_PARAMS } = require('../api/utils');

const TABLE = 'build_task_type';
const TASK_TYPE_NAME = 'owasp-zap-scan'
const env = process.env.APP_ENV || 'local'

exports.up = async (db, callback) => {
await db.insert(TABLE,
['name', 'description', 'metadata', 'createdAt', 'updatedAt', 'runner', 'startsWhen'],
[
TASK_TYPE_NAME,
'Runs an OWASP ZAP scan to find vulnerabilities in the built site',
{
"appName": `pages-owasp-zap-task-${env}`,
"template": {
"command": `zap/run_pages_task.py -t {{task.Build.url}} ${DEFAULT_BUILD_TASK_PARAMS}`,
"disk_in_mb": 3000
}
},
new Date(),
new Date(),
'cf_task',
'complete'
],
callback
);
};

exports.down = async db => {
await db.runSql(`delete from "${TABLE}" where name=\'${TASK_TYPE_NAME}\'`);
};

Loading