-
Notifications
You must be signed in to change notification settings - Fork 42
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
Add a YQ-powered remediation function #4830
Add a YQ-powered remediation function #4830
Conversation
This PR depends on having mindersec/minder#4830 merged first as it takes the remediation function added there into effect. The remediation works as follows: - if there are any instances of pull_request target objects those are removed - else if there are any instances of pull_request strings in an array those are removed - if the resulting array of array of objects would have length 0, `workflow_dispatch` is added instead Fixes: mindersec#201
This PR depends on having mindersec/minder#4830 merged first as it takes the remediation function added there into effect. The remediation works as follows: - if there are any instances of pull_request target objects those are removed - else if there are any instances of pull_request strings in an array those are removed - if the resulting array of array of objects would have length 0, `workflow_dispatch` is added instead Fixes: #201
45fb1d6
to
15e95fe
Compare
The tests seem to be failing with:
which sounds unrelated. I can take into this tomorrow, just going to tag @blkt who was looking into skipping tests lately in case it is a known issue. |
The PR evaluator used to have typed params for every function we'd add - there's one for frizbee, one for the pull_request_content function etc. This is not great, as we tie the functions to our protobuf API and every new function requires a client release to be done or else the clients can't even add ruletypes with the new functions. Let's just use a generic `structpb.Struct` going forward. This time it is still a change that needs client support, but going forward we'll just have to change the server code to add a new function.
In order to be able to change YAML files such as github workflows safely and with minimal amount of changes, we need to add a new remediation function in addition to the put-a-content-somewhere and call-frizbee ones we have now. I chose to add one based on `libyq` which does a decent job at retaining comments and general YAML structure. Fixes: mindersec#4815
15e95fe
to
c20ed0f
Compare
This was resolved by rebasing atop origin/main |
This PR depends on having mindersec/minder#4830 merged first as it takes the remediation function added there into effect. The remediation works as follows: - if there are any instances of pull_request target objects those are removed - else if there are any instances of pull_request strings in an array those are removed - if the resulting array of array of objects would have length 0, `workflow_dispatch` is added instead Fixes: #201
Summary
structpb.Struct
going forward. This time it is still a change that needs client support, but going forward we'll just have to change the server code to add a new function.libyq
which does a decent job at retaining comments and general YAML structure.Fixes: #4815
Change Type
Testing
a mix of manual testing and unit tests. You can see one such PR created by this function here: jakubtestorg/bad-workflows@4b2863b
Review Checklist: