-
Notifications
You must be signed in to change notification settings - Fork 1
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
Lint07 #22
base: lint06
Are you sure you want to change the base?
Conversation
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.
1 Comment on the. readme but LGTM
Example: | ||
|
||
```go | ||
// LintProducedAtDate checks that an OCSP Response ProducedAt date is no more than ProducedAtLimit in the past | ||
// Source: Apple Lints 03 & 05 | ||
func LintProducedAtDate(resp *ocsp.Response, leafCert *x509.Certificate, issuerCert *x509.Certificate) (LintStatus, string) { | ||
// default assume certificate being checked is a subscriber certificate | ||
certType := "subscriber certificate" | ||
producedAtLimit := ProducedAtLimitSubscriber | ||
if leafCert != nil && leafCert.IsCA { | ||
certType = "subordinate CA certificate" | ||
producedAtLimit = ProducedAtLimitCA | ||
// CheckStatus checks that the status of the OCSP response matches what the user expects it to be | ||
// Source: Apple Lint 07 | ||
func CheckStatus(resp *ocsp.Response, leafCert *x509.Certificate, issuerCert *x509.Certificate, lintOpts *LintOpts) (LintStatus, string) { | ||
if lintOpts.ExpectedStatus == None { | ||
return Passed, fmt.Sprintf("User did not specify an expected status (fyi OCSP response status was %s)", StatusIntMap[resp.Status]) | ||
} | ||
|
||
expectedStatus := ocsp.Good | ||
if lintOpts.ExpectedStatus == Revoked { | ||
expectedStatus = ocsp.Revoked | ||
} | ||
|
||
limit, err := time.ParseDuration(producedAtLimit) | ||
|
||
if err != nil { | ||
return Error, fmt.Sprintf("Could not parse time duration %s", producedAtLimit) | ||
} | ||
|
||
if time.Since(resp.ProducedAt) > limit { | ||
return Failed, fmt.Sprintf("OCSP Response producedAt date %s for %s is more than %s in the past", | ||
resp.ProducedAt, certType, DurationToString[producedAtLimit]) | ||
if resp.Status != expectedStatus { | ||
return Failed, fmt.Sprintf("Expected status %s, OCSP response status was %s", lintOpts.ExpectedStatus, StatusIntMap[resp.Status]) | ||
} | ||
|
||
return Passed, fmt.Sprintf("OCSP Response producedAt date %s for %s is within %s of the past", | ||
resp.ProducedAt, certType, DurationToString[producedAtLimit]) | ||
return Passed, fmt.Sprintf("OCSP Response status matched expected status of %s", lintOpts.ExpectedStatus) | ||
} | ||
``` |
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.
Like I think I mentioned in another PR, every time the code changes you'll have to. remember to come back and update this too. It might be better to just point to a file and a function in the file rather than copy-pasting the whole code.
No description provided.