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

Integrate security release approval into release pipeline#63990

Merged
willdollman merged 21 commits into
mainfrom
will/security-integration-release
Jul 24, 2024
Merged

Integrate security release approval into release pipeline#63990
willdollman merged 21 commits into
mainfrom
will/security-integration-release

Conversation

@willdollman

@willdollman willdollman commented Jul 22, 2024

Copy link
Copy Markdown
Contributor

As part of the Vuln Scanning Improvements project, I'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 <version> in the #secbot-commands channel. In an ideal world we (security) will have already gone through and approved ahead of release.

I've tested this PR as much as I can without running an actual release! We have a 5.5.x release tomorrow so it'll be a good test. If it does cause problems that can't be easily solved, it can always be temporarily disabled.

I've tagged this PR to be backported to 5.5.x.

Pre-merge checklist

  • Revert commit that disables release promotion

Test plan

Manual testing of the release process:

Changelog

@willdollman willdollman self-assigned this Jul 22, 2024
@cla-bot cla-bot Bot added the cla-signed label Jul 22, 2024
Comment thread release.yaml Fixed
Comment thread release.yaml Fixed
Comment thread release.yaml Outdated
Comment on lines +237 to +240
- name: 'Check Security Approval'
cmd: |
curl --location 'https://security-manager.sgdev.org/approve-release?release={{tag}}' --header "Authorization: Bearer ${SCANNER_TOKEN}" --fail && "Release {{tag}} has security approval"
|| echo "Release {{tag}} does not have security approval - reach out to the Security Team to resolve."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These steps would run after promotion has happened. We should move them to the cmd that runs the buildkite pipeline

@willdollman willdollman Jul 23, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very true! But that cmd runs locally, so the sec-manager webhook secret won't be available. I've moved them to the runtype.PromoteRelease Buildkite pipeline, though this makes it a little harder to bypass the release approval step in the event something goes wrong.

Comment on lines +14 to +29
// checkSecurityApproval checks whether the specified release has release approval from the Security Team.
func checkSecurityApproval(c Config) operations.Operation {
return func(pipeline *bk.Pipeline) {
pipeline.AddStep("Check security approval",
bk.Agent("queue", AspectWorkflows.QueueDefault),
bk.Env("VERSION", c.Version),
bk.AnnotatedCmd(
"./tools/release/check_security_approval.sh",
bk.AnnotatedCmdOpts{
Annotations: &bk.AnnotationOpts{
Type: bk.AnnotationTypeInfo,
IncludeNames: false,
},
},
),
)

Check notice

Code scanning / Semgrep OSS

Semgrep Finding: security-semgrep-rules.semgrep-rules.generic.comment-tagging-rule

Code that highlight SECURITY in comment has changed. Please review the code for changes. The changes might be sensitive.
Comment thread tools/release/check_security_approval.sh Fixed
Comment thread release.yaml
curl --location 'https://incoming.sgdev.org/new-image-scan?tag={{tag}}&scanType=release&dev=true' --header 'X-Special-Header: ${SCANNER_TOKEN}'
set -eu

curl --location 'https://security-manager.sgdev.org/internal-release-scan?release={{tag}}' --request POST --header "Authorization: Bearer ${SECURITY_SCANNER_TOKEN}"

Check notice

Code scanning / Semgrep OSS

Semgrep Finding: security-semgrep-rules.semgrep-rules.generic.comment-tagging-rule

Code that highlight SECURITY in comment has changed. Please review the code for changes. The changes might be sensitive.
Comment thread tools/release/check_security_approval.sh Fixed
Comment thread tools/release/check_security_approval.sh Fixed
@willdollman willdollman force-pushed the will/security-integration-release branch from 37d9b5c to 2a139b9 Compare July 23, 2024 19:08
@willdollman willdollman marked this pull request as ready for review July 23, 2024 19:09
Comment on lines +22 to +31
curl --location "https://security-manager.sgdev.org/approve-release?release=${VERSION}" \
--header "Authorization: Bearer ${SECURITY_SCANNER_TOKEN}" --fail
SECURITY_APPROVAL=$?

if [ "$SECURITY_APPROVAL" -eq 0 ]; then
echo "Release \`${VERSION}\` has security approval." | tee -a ./annotations/security_approval.md
else
echo -e "Release ${VERSION} does **not** have security approval - reach out to the Security Team to resolve.\n" | tee -a ./annotations/security_approval.md
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
exit 1

Check notice

Code scanning / Semgrep OSS

Semgrep Finding: security-semgrep-rules.semgrep-rules.generic.comment-tagging-rule

Code that highlight SECURITY in comment has changed. Please review the code for changes. The changes might be sensitive.
Comment on lines +22 to +32
curl --location "https://security-manager.sgdev.org/approve-release?release=${VERSION}" \
--header "Authorization: Bearer ${SECURITY_SCANNER_TOKEN}" --fail
SECURITY_APPROVAL=$?

if [ "$SECURITY_APPROVAL" -eq 0 ]; then
echo "Release \`${VERSION}\` has security approval." | tee -a ./annotations/security_approval.md
else
echo -e "Release ${VERSION} does **not** have security approval - reach out to the Security Team to resolve.\n" | tee -a ./annotations/security_approval.md
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
exit 1
fi

Check notice

Code scanning / Semgrep OSS

Semgrep Finding: security-semgrep-rules.semgrep-rules.generic.comment-tagging-rule

Code that highlight SECURITY in comment has changed. Please review the code for changes. The changes might be sensitive.

@Chickensoupwithrice Chickensoupwithrice left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! 🚀 Excited to take it for a spin tomorrow :)

@willdollman willdollman merged commit 9dd901f into main Jul 24, 2024
@willdollman willdollman deleted the will/security-integration-release branch July 24, 2024 08:19
sourcegraph-release-bot pushed a commit that referenced this pull request Jul 24, 2024
As part of the [Vuln Scanning
Improvements](https://linear.app/sourcegraph/project/[p0]-vulnerability-scanning-improvements-75299c4312dd/issues)
project, I'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 <version>` in
the #secbot-commands channel. In an ideal world we (security) will have
already gone through and approved ahead of release.

I've tested this PR as much as I can without running an actual release!
We have a 5.5.x release tomorrow so it'll be a good test. If it does
cause problems that can't be easily solved, it can always be temporarily
disabled.

I've tagged this PR to be backported to `5.5.x`.

<!-- PR description tips:
https://www.notion.so/sourcegraph/Write-a-good-pull-request-description-610a7fd3e613496eb76f450db5a49b6e
-->

## 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

<!-- REQUIRED; info at
https://docs-legacy.sourcegraph.com/dev/background-information/testing_principles
-->

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->

(cherry picked from commit 9dd901f)
willdollman added a commit that referenced this pull request Jul 24, 2024
…eline (#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 <will.dollman@sourcegraph.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants