Repository navigation
Add cve and protocol filters and fields to the feeds. Closes #1819 - #1860
regulartim merged 5 commits into
Conversation
AdeshDeshmukh
left a comment
There was a problem hiding this comment.
i verified locally — filters, case normalization, 400 handling on malformed CVEs, field output across JSON/NDJSON/public rows, and share-token replay all behave exactly as described. Tests green (85/85 module, 558/558 package)..! looks clean..!
however the ai disclosure is absent.! as it's part of the pr template, so worth adding before review..! ig
regulartim
left a comment
There was a problem hiding this comment.
Hey @Akshats-git ! Thanks for your work. Only fond some cosmetic stuff.
As @AdeshDeshmukh mentioned, please add the AI disclosure section again.
Thank you @AdeshDeshmukh for your review.
| REGEX_DOMAIN = r"^[a-zA-Z\d-]{1,60}(\.[a-zA-Z\d-]{1,60})*$" | ||
| REGEX_PASSWORD = r"^(?=.*[a-zA-Z])\S{12,}$" # noqa: S105 | ||
|
|
||
| REGEX_CVE = r"CVE-\d{4}-\d{4,}" |
There was a problem hiding this comment.
Good idea to create a regex for that! There are two other places in the code that use similar regexes:
validate_cve_idin api/serializers/events.pyiocs_from_hitsin extraction/utils.py
Can you swap this copies with the regex you made here, if possible?
There was a problem hiding this comment.
Done. I also bounded it to 10 digits like the extraction regex had it so a CVE always fits the 50 character column. also added 2 tests for it.
|
|
||
| class ReputationListField(serializers.ListField): | ||
| """ListField for the include_reputation and exclude_reputation query params. | ||
| class SemicolonListField(serializers.ListField): |
| cve = SemicolonListField( | ||
| child=serializers.CharField(), | ||
| required=False, | ||
| help_text="`;`-separated CVE IDs (e.g. `CVE-2021-44228`). Only IOCs that were seen exploiting at least one of them.", | ||
| ) | ||
| protocol = SemicolonListField( | ||
| child=serializers.CharField(), | ||
| required=False, | ||
| help_text="`;`-separated protocols (e.g. `ssh;telnet`). Only IOCs that were seen using at least one of them.", | ||
| ) |
There was a problem hiding this comment.
This is a response schema. CVEs and protocols are marked required=False even though the rows always include them. So shouldn't it be required=True?
There was a problem hiding this comment.
oh yes you are right, i did the fix.
regulartim
left a comment
There was a problem hiding this comment.
Hey @Akshats-git ! Thanks for implementing the changes. Basically this is ready to merge. I only found another small nit. Also, there's unfortunately a merge conflict that you have to resolve.
| # width of IOC.protocols items | ||
| MAX_PROTOCOL_LENGTH = 50 | ||
|
|
There was a problem hiding this comment.
I just realized that this information is redundant, as it is already present in the data model. You could read it from IOC._meta.get_field("protocols").base_field.max_length, am I right?
d50a821 to
4d59660
Compare
regulartim
left a comment
There was a problem hiding this comment.
Nice, thank you! :)
Mostly wrote the code myself. Used Claude to confirm its correctness and avoid any linting issues.
I appreciate your honesty and I know how tempting it is to just use Claude, when you have it at hand. I'd strongly recommend you to try to work without it anyway when you are interested in GSoC. I don't care if your code is not as polished, but I care about what your work looks like when no LLM is involved. Keep it up! :)
Also: linting issues can be avoided by just running the linters. ;-)
Description
The advanced feed has two new filters:
cveandprotocol. Both take values separated by;and match IOCs that have any of them. A malformed CVE returns a 400.Every feed row now also has
cvesandprotocolsin JSON and NDJSON. The ASN feed and share tokens accept the new filters too.Related issues
Closes #1819
Type of change
Checklist
Formalities
<feature name>. Closes #999develop.develop.Docs and tests
Ruff) gave 0 errors.GUI changes
No GUI changes.
AI Disclosure
Mostly wrote the code myself. Used Claude to confirm its correctness and avoid any linting issues.