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 support for collecting and recording per-file metadata #63

Merged
merged 17 commits into from
Jun 30, 2023

Conversation

bradlarsen
Copy link
Collaborator

@bradlarsen bradlarsen commented Jun 21, 2023

This pull request adds blob metadata to Nosey Parker.

The scan command now collects and records some basic metadata about blobs (size in bytes, guessed mime type, guessed charset). The guessed metadata is based on path names, and at present only works on plain file inputs and not blobs found in Git history (see #16).

If Nosey Parker is built with the libmagic feature, blob metadata is collected an recorded using an additional content-based mechanism that uses libmagic, which collects this information even for blobs found in Git history that do not have pathnames. This feature slows down scanning time something like 6-10x, and requires additional system-installed libraries to build, and so is not enabled by default.

When scanning, by default, the metadata is collected and recorded only for blobs that have rule matches within them. The collection of blob metadata can be controlled slightly by the new --record-all-blobs <BOOL> command-line option; a true value causes all discovered blobs to have metadata collected and recorded, not just those with rule matches.

The report command makes use of the newly collected metadata. In all output formats, the metadata is included.

Additionally in this pull request: the performance of scanning on certain match-heavy workloads has been improved as much as 2x. This was achieved through using fewer sqlite transactions in the datastore implementation.

@bradlarsen bradlarsen added enhancement New feature or request detection Related to rules or detection of sensitive information labels Jun 21, 2023
@bradlarsen bradlarsen self-assigned this Jun 21, 2023
@bradlarsen bradlarsen marked this pull request as ready for review June 30, 2023 22:34
@bradlarsen bradlarsen merged commit 3626257 into main Jun 30, 2023
5 checks passed
@bradlarsen bradlarsen deleted the file-metadata branch June 30, 2023 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
detection Related to rules or detection of sensitive information enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant