Fix comparison logic and snyk stage naming conventions #11545
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR will be identical for all repositories.
MACPRO took an approach of relaying all Snyk generated builds into a single ephemeral environment. This is accomplished by setting the number of PRs Snyk can create outstanding to be one per project, and by setting a concurrency group in GHA workflow to ensure only one Synk build can occur at a time. This makes sense for keeping infrastructure costs down, but it creates the situation where builds don't match the health of the environment, such that a successful build after a failed one will rectify the environment. This is probably not much of a concern, but it's worth pointing out they are using OpenSearch and significantly more expensive infrastructure, and that limiting the creation of Snyk generated branches is only applicable at a service (package.json) level, so instead, I took the approach of correcting the environment switch such that Snyk will generate one build per branch, but I link these builds against the Synk hash and truncate the branch name to avoid failures.
Dependabot branches are done much in the same way, where an m5sum is created from the branch name and truncated to 10 characters, with an 'x' appended, such that the result will be x0000000000. The previous fix put in place doesn't correctly capture the branch name and failed the check, and would attempt to create Cloudformation templates using the full Synk generated branch name. Instead I've put in a basic regular expression that greedily matches snyk-fix-xxx and snyk-upgrade-xxx, but I'm stripping the first 10 characters from the hash Snyk appends to the name in order to easily link a branch to the created infrasturcture, such that the branch name
snyk-upgrade-02ff80f020e0ac03d1ada0575a20f214
will appears ass02ff80f020
as a stack namespace.Implementing this fix requires a few steps, manual in nature:
Some changes to Snyk configuration were made during the development of this work, but those changes have been reversed.
Related ticket(s)
CMDCT-3081
How to test
This PR is essentially a no-op for a normal build path. Successful application will be demonstrated by Snyk generated branches being able to successfully build infrastructure and pass tests.
Important updates
The behavior of Dependabot has not been altered but it is reasonable to remove it from the toolset given the overlap against Snyk. The changes are very minor and mainly related to correcting parsing of the branch references.
Author checklist
convert to a different template: test → val | val → prod