Skip to content

Single match expression should run multiple regex types#553

Merged
eddynaka merged 6 commits into
mainfrom
users/ednakamu/enabling-multiple-regex-types
Sep 9, 2021
Merged

Single match expression should run multiple regex types#553
eddynaka merged 6 commits into
mainfrom
users/ednakamu/enabling-multiple-regex-types

Conversation

@eddynaka

@eddynaka eddynaka commented Sep 8, 2021

Copy link
Copy Markdown
Collaborator

Changes

Please provide a brief description of the changes here.

For significant contributions please make sure you have completed the following items:

  • ReleaseHistory.md updated for non-trivial changes
  • Added unit tests


private void RunMatchExpression(FlexMatch binary64DecodedMatch, AnalyzeContext context, MatchExpression matchExpression)
{
bool isMalformed = true;

@eddynaka eddynaka Sep 8, 2021

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

isMalformed

this change will enable a rule to have:

  • ContentsRegex
  • IntrafileRegexes
  • SinglelineRegexes

the idea is to re-use the match expression instead of duplicating it. #ByDesign

// to avoid re-entrance in cases where our logic below fails
string assemblyName = args.Name.Split(',')[0];
if (this._resolvedNames.ContainsKey(assemblyName))
if (this._resolvedNames.TryGetValue(assemblyName, out resolved))

@eddynaka eddynaka Sep 8, 2021

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

TryGetValue

performance change. #ByDesign

@eddynaka eddynaka changed the title Single rule can run multiple regex type Single match expression can run multiple regex types Sep 8, 2021
@eddynaka eddynaka changed the title Single match expression can run multiple regex types Single match expression should run multiple regex types Sep 8, 2021
Comment thread Src/ReleaseHistory.md Outdated
`SEC101/036.MySqlCredential`, `SEC101/037.SqlCredentials`,
`SEC101/038.PostgreSqlCredentials` won't accept spaces in `id` and `secret`.
[#550](https://github.com/microsoft/sarif-pattern-matcher/pull/550)
- PRF: Single match expression can run multiple regex types.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

PRF

SDK?


if (matchExpression.IntrafileRegexes?.Count > 0 ||
matchExpression.SingleLineRegexes?.Count > 0)
else

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

else

use else if { here

// to avoid re-entrance in cases where our logic below fails
string assemblyName = args.Name.Split(',')[0];
if (this._resolvedNames.ContainsKey(assemblyName))
if (this._resolvedNames.TryGetValue(assemblyName, out resolved))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this

'this.' is not the standard for this file.

@michaelcfanning michaelcfanning left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

:shipit:

@eddynaka eddynaka merged commit baa9518 into main Sep 9, 2021
@eddynaka eddynaka deleted the users/ednakamu/enabling-multiple-regex-types branch September 9, 2021 00:44
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