Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit 0f4cbff

Browse files
[Backport 5.5.x] Integrate security release approval into release pipeline (#64030)
As part of the [Vuln Scanning Improvements](https://linear.app/sourcegraph/project/[p0]-vulnerability-scanning-improvements-75299c4312dd/issues) project, I&#39;ve been working on tooling to automate the security approval step of the release process. This PR integrates these improvements into the release pipeline: * Internal releases will run a vulnerability scan * Promote-to-public releases will check for security approval If a public release does not have security approval, it will block the promotion process. The step happens at the start of the pipeline so should be a fast-fail. You can also check for release approval before running promotion by running `@secbot cve approve-release &lt;version&gt;` in the #secbot-commands channel. In an ideal world we (security) will have already gone through and approved ahead of release. I&#39;ve tested this PR as much as I can without running an actual release! We have a 5.5.x release tomorrow so it&#39;ll be a good test. If it does cause problems that can&#39;t be easily solved, it can always be temporarily disabled. I&#39;ve tagged this PR to be backported to `5.5.x`. ## Pre-merge checklist - [x] Revert commit that disables release promotion ## Test plan Manual testing of the release process: - [x] [Successful test run](https://buildkite.com/sourcegraph/sourcegraph/builds/283774#0190dfd6-fa70-4cea-9711-f5b8493c7714) that shows the security scan being triggered - [x] [Promote to public test run](https://buildkite.com/sourcegraph/sourcegraph/builds/283826) that shows the security approval approving a release - [x] [Promote to public test run](https://buildkite.com/sourcegraph/sourcegraph/builds/283817#0190e0ec-0641-4451-b7c7-171e664a3127) that shows the security approval rejecting a release with un-accepted CVEs ## Changelog <br> Backport 9dd901f from #63990 Co-authored-by: Will Dollman <[email protected]>
1 parent 1a463ba commit 0f4cbff

File tree

4 files changed

+56
-1
lines changed

4 files changed

+56
-1
lines changed

dev/ci/internal/ci/pipeline.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,8 @@ func GeneratePipeline(c Config) (*bk.Pipeline, error) {
275275
)
276276
case runtype.PromoteRelease:
277277
ops = operations.NewSet(
278+
checkSecurityApproval(c),
279+
wait,
278280
releasePromoteImages(c),
279281
wait,
280282
releaseTestOperation(c),

dev/ci/internal/ci/release_operations.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,25 @@ import (
1111
"github.com/sourcegraph/sourcegraph/dev/ci/internal/ci/operations"
1212
)
1313

14+
// checkSecurityApproval checks whether the specified release has release approval from the Security Team.
15+
func checkSecurityApproval(c Config) operations.Operation {
16+
return func(pipeline *bk.Pipeline) {
17+
pipeline.AddStep(":nodesecurity: Check security approval",
18+
bk.Agent("queue", AspectWorkflows.QueueDefault),
19+
bk.Env("VERSION", c.Version),
20+
bk.AnnotatedCmd(
21+
"./tools/release/check_security_approval.sh",
22+
bk.AnnotatedCmdOpts{
23+
Annotations: &bk.AnnotationOpts{
24+
Type: bk.AnnotationTypeInfo,
25+
IncludeNames: false,
26+
},
27+
},
28+
),
29+
)
30+
}
31+
}
32+
1433
// releasePromoteImages runs a script that iterates through all defined images that we're producing that has been uploaded
1534
// on the internal registry with a given version and retags them to the public registry.
1635
func releasePromoteImages(c Config) operations.Operation {

release.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ internal:
7575
fi
7676
- name: 'Trigger Security scan'
7777
cmd: |
78-
curl --location 'https://incoming.sgdev.org/new-image-scan?tag={{tag}}&scanType=release&dev=true' --header 'X-Special-Header: ${SCANNER_TOKEN}'
78+
set -eu
79+
80+
curl --location 'https://security-manager.sgdev.org/internal-release-scan?release={{tag}}' --request POST --header "Authorization: Bearer ${SECURITY_SCANNER_TOKEN}"
7981
- name: 'notifications'
8082
cmd: |
8183
set -eu
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
3+
set -uo pipefail
4+
5+
if [ -z "$VERSION" ]; then
6+
echo "❌ Need \$VERSION to be set to check security approval"
7+
exit 1
8+
fi
9+
10+
if [ -z "$SECURITY_SCANNER_TOKEN" ]; then
11+
echo "❌ Need \$SECURITY_SCANNER_TOKEN to be set to check security approval"
12+
exit 1
13+
fi
14+
15+
echo "Checking security approval for release ${VERSION}..."
16+
17+
if [ ! -e "./annotations" ]; then
18+
mkdir ./annotations
19+
fi
20+
echo -e "## :nodesecurity: Security Release Approval" >./annotations/security_approval.md
21+
22+
curl --location "https://security-manager.sgdev.org/approve-release?release=${VERSION}" \
23+
--header "Authorization: Bearer ${SECURITY_SCANNER_TOKEN}" --fail
24+
SECURITY_APPROVAL=$?
25+
26+
if [ "$SECURITY_APPROVAL" -eq 0 ]; then
27+
echo "Release \`${VERSION}\` has security approval." | tee -a ./annotations/security_approval.md
28+
else
29+
echo -e "Release ${VERSION} does **not** have security approval - reach out to the Security Team to resolve.\n" | tee -a ./annotations/security_approval.md
30+
echo "Run \`@SecBot cve approve-release 5.5.1339\` in [#secbot-commands](https://sourcegraph.slack.com/archives/C07BQJDFCV8) to check the approval status." | tee -a ./annotations/security_approval.md
31+
exit 1
32+
fi

0 commit comments

Comments
 (0)