-
Notifications
You must be signed in to change notification settings - Fork 0
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
Centralize malicious #132
Draft
Robin5605
wants to merge
9
commits into
main
Choose a base branch
from
centralize-malicious
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Centralize malicious #132
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add inspector URL to `first_safe_second_malicious.json` to records that have a score greater than 0 (since packages that match rules *must* have an inspector URL). This was done because of the conditional in L34-35 of `src/endpoints/scans.py`: ```py if scan.inspector_url is None: continue ``` The previous conditional that checks the score should ensure that the inspector_url is never actually null in a production environment where we get real data instead of our own fed in from test data. However, since we use one big table for everything, most of our columns are nullable and and "runtime checked." This means that even though the `inspector_url` will always not be null if the score is greater than 0, the type-checker doesn't know this. So this is mostly a check to appease the typechecker.
Add a `score_threshold` field to the `MainframeSettings` configuration class in `constants.py` that determines the minimum score required for a scan to show up in the `malicious_packages` field of `GET /scans` response. This score determines what packages are considered "malicious"
Add a new `GET /scans` endpoint under `src/mainframe/endpoints/scans.py` This endpoint takes one query string parameter, `since`, which is the UNIX epoch timestamp. It returns two fields: `all_scans` and `malicious_packages`. `all_scans` returns the package name and version of all packages that were scanned since `since`, while `malicious_packages` returns a list of packages that have a score higher than the set `score_threshold`.
I thought we had a /scans since endpoint already? I feel like I've seen it in the logs. Unless you moved things around. |
Yeah, that's what this PR originally added. I wanted to see if a websocket would be feasible, but I don't think it is anymore. We'd have to handle things like CD redeployments, disconnects, etc. Stateless HTTP might just be better. |
Robin5605
force-pushed
the
centralize-malicious
branch
from
July 26, 2023 18:43
94022c0
to
6fe5427
Compare
…into centralize-malicious
…into centralize-malicious
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Blocked by #131
Closes #95
constants.py
that allows tweaking the score thresholdGET /scans
that returns a list of all packages scanned sincesince
, and a list of malicious packages.