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

Add native filetype + compression detection #1929

Merged
merged 3 commits into from
Nov 7, 2024
Merged

Add native filetype + compression detection #1929

merged 3 commits into from
Nov 7, 2024

Conversation

TheTechromancer
Copy link
Collaborator

@TheTechromancer TheTechromancer commented Nov 7, 2024

This PR updates the FILESYSTEM event to autodetect the file content type and compression using magic bytes.

    # test filesystem event - file
    scan = Scanner()
    event = scan.make_event({"path": zip_file}, "FILESYSTEM", parent=scan.root_event)
    assert event.data == {
        "path": "/tmp/.bbottestzipasdkfjalsdf.zip",
        "magic_extension": ".zip",
        "magic_mime_type": "application/zip",
        "magic_description": "PKZIP Archive file",
        "magic_confidence": 0.9,
        "compression": "zip",
    }
    assert event.tags == {"file", "zip-archive", "compressed"}

    # test filesystem event - folder
    scan = Scanner()
    event = scan.make_event({"path": "/tmp"}, "FILESYSTEM", parent=scan.root_event)
    assert event.data == {"path": "/tmp"}
    assert event.tags == {"folder"}

@domwhewell-sage

Copy link

codecov bot commented Nov 7, 2024

Codecov Report

Attention: Patch coverage is 98.36066% with 1 line in your changes missing coverage. Please review.

Project coverage is 93%. Comparing base (72a250a) to head (1cb32e2).
Report is 6 commits behind head on dev.

Files with missing lines Patch % Lines
bbot/core/helpers/libmagic.py 92% 1 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##             dev   #1929   +/-   ##
=====================================
- Coverage     93%     93%   -0%     
=====================================
  Files        356     357    +1     
  Lines      27530   27580   +50     
=====================================
+ Hits       25389   25418   +29     
- Misses      2141    2162   +21     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@TheTechromancer TheTechromancer merged commit 17a55eb into dev Nov 7, 2024
14 checks passed
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