Skip to content
This repository has been archived by the owner on Jun 21, 2022. It is now read-only.

fix(secrets): skip aws secrets of greater length #514

Merged
merged 4 commits into from
May 12, 2022
Merged

Conversation

DmitriyLewen
Copy link
Collaborator

Description

Changed regex for aws-secret-access-key:

  • added prefix check: currently we get all secrets with key prefix(like publicKey=*****).
  • added secret length check. We should get secrets with only 40 characters after =(like aws_key=*****asdWef).

Related Issues

@DmitriyLewen DmitriyLewen self-assigned this May 5, 2022
Copy link
Collaborator

@knqyf263 knqyf263 left a comment

Choose a reason for hiding this comment

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

We should add tests for legitimate AWS key and invalid values like Base64.

@@ -78,7 +88,7 @@ var builtinRules = []Rule{
Category: CategoryAWS,
Severity: "CRITICAL",
Title: "AWS Secret Access Key",
Regex: MustCompile(`(?i)["']?(aws)?_?(secret)?_?(access)?_?key["']?\s*(:|=>|=)\s*(?P<secret>["']?[A-Za-z0-9\/\+=]{40})["']?`),
Regex: MustCompile(`(?i)` + startSecret + quote + aws + `(secret)?_?(access)?_?key` + quote + connect + quote + `(?P<secret>[A-Za-z0-9\/\+=]{40})` + quote + endSecret),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we use fmt.Sprintf?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants