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

feat: Add support for analysis in checkers #27

Open
maharshi-deepsource opened this issue Feb 12, 2025 · 1 comment
Open

feat: Add support for analysis in checkers #27

maharshi-deepsource opened this issue Feb 12, 2025 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@maharshi-deepsource
Copy link
Contributor

Checkers need support for analyzers to enhance their analysis. While a checker can identify vulnerable patterns based on code patterns, additional analysis may sometimes be required to accurately filter out false positives.

For example, analysis for hardcoded tokens in code will require an entropy analyzer.

This is a valid vulnerable pattern that should be detected by globstar

a = some_function(token="hqd#18ey283y28wdbbcwbd1ueh1ue2h")

However, using only regex based matching will also detect false positives like this

a = some_function(token="fake_token_as_placeholder")

An entropy analyzer will help differentiate between them more effectively. Here’s an overview of how the workflow might look after integrating the analyzer feature.

language: py
name: hardcoded-tokens
message: Look for hardcoded tokens
category: security

pattern: |
   (assignment
       left: (identifier)
       right: (call
             function: (identifier) @func_name
            arguments: (argument_list
                (keyword_argument:
                    name: (identifier)
                    value: (string
                        (string_start)
                        (string_content) @token_val
                        (string_end))))
         (#match? @token_val "^[A-Za-z0-9/+=]+$")) @hardcoded-tokens

analyzers: |
    entropy @token_val

description: |
   Do not provide hardcoded token values in functions.
@burntcarrot
Copy link

@maharshi-deepsource #129 should probably help, please close if I misunderstood the context behind the analyzers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants