-
Notifications
You must be signed in to change notification settings - Fork 121
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
Introduce gosec
for Static Application Security Testing (SAST)
#954
Conversation
Thank you @thiyyakat for your contribution. Before I can start building your PR, a member of the organization must set the required label(s) {'reviewed/ok-to-test'}. Once started, you can check the build status in the PR checks section below. |
ccead38
to
9451a92
Compare
@thiyyakat You need rebase this pull request with latest master branch. Please check. |
9451a92
to
b621749
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
|
||
.PHONY: sast | ||
sast: $(GOSEC) | ||
@chmod +xw hack/sast.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this required? When you introduce a new script you already give it execute permissions and then onwards those permissions are preserved and therefore there is no real need to add this as part of the make target.
|
||
.PHONY: sast-report | ||
sast-report:$(GOSEC) | ||
@chmod +xw hack/sast.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as the comment for sast
target.
|
||
if spec.Replicas < 0 { | ||
allErrs = append(allErrs, field.Required(fldPath.Child("replicas"), "Replicas has to be a whole number")) | ||
func canConvertIntOrStringToInt32(val *intstr.IntOrString, replicas int) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a very generic function, can we move elsewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's used here only. If we feel like it is required elsewhere, then we'll put it in separate location
if spec.Strategy.Type != "RollingUpdate" && spec.Strategy.Type != "Recreate" { | ||
allErrs = append(allErrs, field.Required(fldPath.Child("strategy.type"), "Type can either be RollingUpdate or Recreate")) | ||
} | ||
if spec.Strategy.Type == "RollingUpdate" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use:
if spec.Strategy.Type == v1alpha1.MachineDeploymentStrategyType
instead
if spec.Strategy.Type != "RollingUpdate" && spec.Strategy.Type != "Recreate" { | ||
allErrs = append(allErrs, field.Required(fldPath.Child("strategy.type"), "Type can either be RollingUpdate or Recreate")) | ||
} | ||
if spec.Strategy.Type == "RollingUpdate" { | ||
if spec.Strategy.RollingUpdate == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this check done?
As per the doc string if MaxUnavailable is not specified then By default, a fixed value of 1 is used.
Similarly for MaxSurge
its mentioned that By default, a value of 1 is used.
So either the doc string needs correction or this check needs to be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The doc string is incorrect. If both are zero then we use maxUnavailable
as 1.
…dener#954) * Introduce make targets for sast and address security issues. * Address review comments
What this PR does / why we need it:
This PR introduces two make targets:
sast
andsast-report
to rungosec
for Static Application Security Testing. Additionally, it also addresses the security vulnerabilities in the MCM repository. It uses the default ruleset of gosec from gardener/gardener as introduced in gardener/gardener#9959.sast-report
target has also been added as a dependency for thecheck
target.Which issue(s) this PR fixes:
Partially fixes #948
Special notes for your reviewer:
Tested manually to check if gosec is downloaded and installed to
hack/tools/bin
, if not already present, on runningmake sast
andmake sast-report
.Integration tests passed with provider-aws.
Release note: