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

YARA rules for setup.py not ignoring comments #7475

Closed
di opened this issue Feb 29, 2020 · 3 comments
Closed

YARA rules for setup.py not ignoring comments #7475

di opened this issue Feb 29, 2020 · 3 comments
Assignees
Labels
bug 🐛 malware-detection Issues related to automated malware detection.

Comments

@di
Copy link
Member

di commented Feb 29, 2020

Looking at a verdict from a release on TestPyPI (https://test.pypi.org/admin/verdicts/530819ab-b0bb-4405-8474-bea1c7aed983) it indicates that there are calls to exec:

{
    "process_spawn_in_setup": {
        "classification": "threat",
        "confidence": "high",
        "strings": [
            [
                247,
                "$from_os_import"
            ],
            [
                7794,
                "$bare_exec"
            ],
            [
                7977,
                "$bare_exec"
            ],
            [
                8110,
                "$bare_exec"
            ]
        ]
    }
}

However there aren't any exec calls in the package, instead it seems to be picking up on the following comments in setup.py:

    # To provide executable scripts, use entry points in preference to the
    # "scripts" keyword. Entry points provide cross-platform support and allow
    # `pip` to create the appropriate form of executable for the target
    # platform.
    #
    # For example, the following would provide a command called `sample` which
    # executes the function `main` from this package when invoked:

Due to the following rule:

https://github.com/pypa/warehouse/blob/630ac09321d93a6867f2b801153f45a90ba50d58/warehouse/malware/checks/setup_patterns/setup_py_rules.yara#L18

Is there a way we can exclude all lines that are comments?

@di di added bug 🐛 malware-detection Issues related to automated malware detection. labels Feb 29, 2020
@xmunoz
Copy link
Contributor

xmunoz commented Mar 14, 2020

I'm happy to take a look :)

@xmunoz xmunoz self-assigned this Mar 14, 2020
@xmunoz
Copy link
Contributor

xmunoz commented Mar 21, 2020

Doesn't look like yara supports negative lookaheads, so we'll have to great creative with the condition clause. VirusTotal/yara#584

@dstufft
Copy link
Member

dstufft commented May 23, 2023

This is gone now #13647

@dstufft dstufft closed this as not planned Won't fix, can't repro, duplicate, stale May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 malware-detection Issues related to automated malware detection.
Projects
None yet
Development

No branches or pull requests

3 participants