Skip to content

LG-11122 add gitlab secret scanning#9296

Merged
soniaconnolly merged 4 commits intomainfrom
sonia-lg-11122-add-gitlab-secret-scanning
Oct 4, 2023
Merged

LG-11122 add gitlab secret scanning#9296
soniaconnolly merged 4 commits intomainfrom
sonia-lg-11122-add-gitlab-secret-scanning

Conversation

@soniaconnolly
Copy link
Contributor

@soniaconnolly soniaconnolly commented Oct 2, 2023

🎫 Ticket

LG-11122

🛠 Summary of changes

We want to be clearly notified if sensitive information is accidentally pushed to a Github branch. This enables Secret Detection in Gitlab and will fail the build if the branch contains a secret. PR #9273 has these same commits with a demo "secret".
Failing secret_detection job

Note that this is not foolproof because it won't necessarily scan all commits in a newly pushed branch. And we still need to take mitigation measures if a secret is pushed up to Github, even briefly.

The detected secrets don't show up in the Gitlab Security tab, possibly because the job fails, since they did show up when the job succeeds but detects a secret (from @mitchellhenke's original PR implementing this).

if [ -f "$SECRET_DETECTION_REPORT_FILE" ]; then
if [ "$(jq ".vulnerabilities | length" $SECRET_DETECTION_REPORT_FILE)" -gt 0 ]; then
echo "Vulnerabilities detected. Please analyze the artifact $SECRET_DETECTION_REPORT_FILE produced by the 'secret-detection' job."
exit 80
Copy link
Contributor

Choose a reason for hiding this comment

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

Q: is the 80 relevant or can it be any non-zero exit code?

Copy link
Contributor Author

@soniaconnolly soniaconnolly Oct 2, 2023

Choose a reason for hiding this comment

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

I don't know, @mitchellhenke did this part.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was actually copied from this forum post. As far as I can tell, Gitlab fails on any non-zero exit code, like you said. Would you like me to change it, or add a comment?

This was referenced Oct 2, 2023
@soniaconnolly soniaconnolly merged commit b2e13d9 into main Oct 4, 2023
@soniaconnolly soniaconnolly deleted the sonia-lg-11122-add-gitlab-secret-scanning branch October 4, 2023 22:14
@jmhooper jmhooper mentioned this pull request Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants