feat(google-ti-feeds): skip attack_techniques API call when counter is 0 (#6562)#6667
Open
romain-filigran wants to merge 4 commits into
Open
feat(google-ti-feeds): skip attack_techniques API call when counter is 0 (#6562)#6667romain-filigran wants to merge 4 commits into
romain-filigran wants to merge 4 commits into
Conversation
…s 0 (#6562) Add a guard condition in orchestrators to avoid fetching attack_techniques relationships when the entity's counters.attack_techniques field is explicitly 0. This optimization reduces unnecessary API calls, primarily for vulnerabilities (~3000+ calls/day saved). - Add _filter_subentity_types() helper to BaseOrchestrator - Pass entity to filter before calling fetch_subentities in all orchestrators
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6667 +/- ##
===========================================
- Coverage 29.77% 6.92% -22.85%
===========================================
Files 1933 1885 -48
Lines 120805 119840 -965
===========================================
- Hits 35964 8298 -27666
- Misses 84841 111542 +26701
📢 Thoughts on this report? Let us know! 🚀 New features to boost your workflow:
|
jabesq
requested changes
Jun 11, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR optimizes the google-ti-feeds connector’s relationship resolution by using GTI entities’ attributes.counters to avoid unnecessary relationship fetches (notably attack_techniques) when the counter is explicitly 0, reducing avoidable API calls as described in issue #6562.
Changes:
- Added
BaseOrchestrator._filter_subentity_types()to drop subentity types whose corresponding counter is0. - Updated orchestrators to pass the current entity into the filter before calling
fetch_subentities. - Updated GTI debug response fixtures (formatting + counter values) used by the test harness.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| external-import/google-ti-feeds/connector/src/custom/orchestrators/base_orchestrator.py | Adds counters-based filtering helper for subentity fetch types. |
| external-import/google-ti-feeds/connector/src/custom/orchestrators/vulnerability/orchestrator_vulnerability.py | Applies filtering before fetching vulnerability relationships. |
| external-import/google-ti-feeds/connector/src/custom/orchestrators/threat_actor/orchestrator_threat_actor.py | Applies filtering before fetching threat actor relationships. |
| external-import/google-ti-feeds/connector/src/custom/orchestrators/software_toolkit/orchestrator_software_toolkit.py | Applies filtering before fetching software toolkit relationships. |
| external-import/google-ti-feeds/connector/src/custom/orchestrators/report/orchestrator_report.py | Applies filtering before fetching report relationships. |
| external-import/google-ti-feeds/connector/src/custom/orchestrators/malware/orchestrator_malware.py | Applies filtering before fetching malware family relationships. |
| external-import/google-ti-feeds/connector/src/custom/orchestrators/campaign/orchestrator_campaign.py | Applies filtering before fetching campaign relationships. |
| external-import/google-ti-feeds/tests/custom/debug_responses/main_vulnerabilities_1a6f110bd333906d.json | Updates debug fixture payload (formatting and counters). |
| external-import/google-ti-feeds/tests/custom/debug_responses/main_reports_1db15afcd82769e5.json | Updates debug fixture payload (formatting and counters). |
Comment on lines
+132
to
+158
| @staticmethod | ||
| def _filter_subentity_types(subentity_types: list[str], entity: Any) -> list[str]: | ||
| """Filter subentity types based on the entity's counters. | ||
|
|
||
| When the entity exposes a ``counters`` object (via ``attributes.counters``), | ||
| subentity types whose counter is explicitly ``0`` are removed from the | ||
| list to avoid unnecessary API calls. | ||
|
|
||
| See: https://github.com/OpenCTI-Platform/connectors/issues/6562 | ||
|
|
||
| Args: | ||
| subentity_types: The full list of subentity types to fetch. | ||
| entity: The GTI entity object (must have ``attributes.counters``). | ||
|
|
||
| Returns: | ||
| A filtered list of subentity types worth fetching. | ||
|
|
||
| """ | ||
| counters = getattr(getattr(entity, "attributes", None), "counters", None) | ||
| if counters is None: | ||
| return subentity_types | ||
|
|
||
| return [ | ||
| subentity_type | ||
| for subentity_type in subentity_types | ||
| if getattr(counters, subentity_type, None) != 0 | ||
| ] |
This file contains hidden or 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
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.
Proposed changes
Related issues
Checklist
Further comments