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

fix(secret): add newline escaping for asymmetric private key #2532

Merged
merged 4 commits into from
Jul 31, 2022

Conversation

DmitriyLewen
Copy link
Contributor

Description

Added newline escaping for Asymmetric Private Key.

Related issues

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

@DmitriyLewen DmitriyLewen self-assigned this Jul 18, 2022
@DmitriyLewen DmitriyLewen marked this pull request as ready for review July 26, 2022 05:37
@DmitriyLewen DmitriyLewen requested a review from knqyf263 as a code owner July 26, 2022 05:37
@knqyf263 knqyf263 requested a review from afdesk July 26, 2022 18:55
@knqyf263
Copy link
Collaborator

I requested a review from @afdesk

@@ -149,7 +149,7 @@ var builtinRules = []Rule{
Category: CategoryAsymmetricPrivateKey,
Title: "Asymmetric Private Key",
Severity: "HIGH",
Regex: MustCompile(`(?i)-----\s*?BEGIN[ A-Z0-9_-]*?PRIVATE KEY( BLOCK)?\s*?-----[\s]*?(?P<secret>[A-Za-z0-9=+/\r\n]+)[\s]*?-----\s*?END[ A-Z0-9_-]*? PRIVATE KEY( BLOCK)?\s*?-----`),
Regex: MustCompile(`(?i)-----\s*?BEGIN[ A-Z0-9_-]*?PRIVATE KEY( BLOCK)?\s*?-----[\s]*?(?P<secret>[A-Za-z0-9=+/\\\r\n]+)[\s]*?-----\s*?END[ A-Z0-9_-]*? PRIVATE KEY( BLOCK)?\s*?-----`),
Copy link
Contributor

Choose a reason for hiding this comment

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

can we add tests for this regex?

Copy link
Contributor

Choose a reason for hiding this comment

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

or did i miss something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks!
I added tests.

Copy link
Contributor

@afdesk afdesk left a comment

Choose a reason for hiding this comment

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

as for me, a lot of * looks not well, I'd prefer five stars
imho

@knqyf263
Copy link
Collaborator

We started with ***** for long secrets, but @liamg changed it in #2410. I guess he needed the same length as the original secret for this kind of output.
image

@knqyf263 knqyf263 merged commit 3cd88ab into main Jul 31, 2022
@knqyf263 knqyf263 deleted the fix/add-escaped-asymmetricprivatekey branch July 31, 2022 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiline secrets stored in json files not picked up due to regexes not matching escaped newlines
3 participants