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

Support for C, C++ and C# secrets in Keyword plugin #429

Merged
merged 4 commits into from
Apr 9, 2021
Merged

Support for C, C++ and C# secrets in Keyword plugin #429

merged 4 commits into from
Apr 9, 2021

Conversation

pablosnt
Copy link
Contributor

This Pull Request introduces some regex in the KeywordDetector plugin to detect secrets in C, C++ and C# files. Some examples of this secrets are:

C:
char* password = "foo";
char password[25] = "foo";

C++:
string secret = "foo";
std::string secret("foo");
secret.assign("foo",17);

C#:
string password = @"foo";
string password = "foo";
string password[] = "foo";

@pablosnt
Copy link
Contributor Author

Hi @domanchi, what do you think about that? Thank you!

Copy link
Contributor

@domanchi domanchi left a comment

Choose a reason for hiding this comment

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

Fix and ship!

I checked ~200 of our internal repositories with the new SQUARE_BRACKETS regex, and it looks sane to me. We don't have C++ code internally to test on, but your regex looks sane to me.

denylist=DENYLIST_REGEX,
square_brackets=SQUARE_BRACKETS,
optional_whitespace=OPTIONAL_WHITESPACE,
secret=SECRET,
),
flags=re.IGNORECASE,
)
FOLLOWEB_BY_OPTIONAL_ASSIGN_QUOTES_REQUIRED_REGEX = re.compile(
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
FOLLOWEB_BY_OPTIONAL_ASSIGN_QUOTES_REQUIRED_REGEX = re.compile(
FOLLOWED_BY_OPTIONAL_ASSIGN_QUOTES_REQUIRED_REGEX = re.compile(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yes, thank you for report it! It's corrected

@domanchi domanchi merged commit 194f4c1 into Yelp:master Apr 9, 2021
killuazhu pushed a commit to IBM/detect-secrets that referenced this pull request May 11, 2021
* Fix divide by zero bug

Fixes user reported bug (see [Slack thread](https://ibm-whitewater.slack.com/archives/CDMGJ9QG2/p1620408289067500))

* Fix safety check
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.

2 participants