Skip to content
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

Implement security policy validator for real #393

Merged
merged 1 commit into from
Jul 11, 2018

Conversation

MrHohn
Copy link
Member

@MrHohn MrHohn commented Jul 11, 2018

This PR teaches security policy validator to actually check for response's status code.
/assign @rramkumar1 @bowei

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 11, 2018
case "deny(502)":
expectedCode = 502
default:
return fuzz.CheckResponseContinue, fmt.Errorf("unregonized rule %q", policy.Rules[0].Action)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: "unrecognized"

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, fixed.

@@ -112,7 +112,10 @@ func ServiceMapFromIngress(ing *v1beta1.Ingress) ServiceMap {
for _, path := range rule.HTTP.Paths {
hp := HostPath{Host: rule.Host, Path: path.Path}
if _, ok := ret[hp]; !ok {
ret[hp] = &path.Backend
// Copy the value over to a new struct so that we won't be
Copy link
Contributor

Choose a reason for hiding this comment

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

What was the purpose for this change?

Copy link
Member Author

Choose a reason for hiding this comment

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

During the test I found we are saving the same pointer for path.Backend in this for loop because path is defined in the init statement.

Ref https://golang.org/ref/spec#For_statements: "Variables declared by the init statement are re-used in each iteration."

@MrHohn MrHohn force-pushed the security-policy-checkresponse branch from 50dbb92 to 9f87dd1 Compare July 11, 2018 22:24
@rramkumar1
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 11, 2018
@nicksardo nicksardo merged commit 2facce1 into kubernetes:master Jul 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants