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

fix(Sekoia): Prevent adding multiple times Sekoia.io as reference #2682

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions external-import/sekoia/src/sekoia.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,21 @@ def _clean_external_references_fields(self, items: List[Dict]):
Remove empty values from external references and add link to original object in Sekoia.io platform
"""
for item in items:
item["external_references"] = [
{k: v for k, v in ref.items() if v}
for ref in item.get("external_references", [])
]
item["external_references"].append(
{
"source_name": "Sekoia.io",
"url": f"https://app.sekoia.io/intelligence/objects/{item['id']}",
}
)
has_sekoia_source = False
external_references = item.setdefault("external_references", [])
for ref in external_references:
if ref.get("source_name") == "Sekoia.io":
has_sekoia_source = True
for key in list(ref.keys()):
if not ref[key]:
del ref[key]
if not has_sekoia_source:
external_references.append(
{
"source_name": "Sekoia.io",
"url": f"https://app.sekoia.io/intelligence/objects/{item['id']}",
}
)

def _clean_ic_fields(self, items: List[Dict]) -> List[Dict]:
"""
Expand Down