Skip to content

[MISP] Handle case where MISP Distribution and Threat Level IDs are of type int #3994

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

Open
gbikram opened this issue May 16, 2025 · 0 comments
Labels
bug use for describing something not working as expected needs triage use to identify issue needing triage from Filigran Product team

Comments

@gbikram
Copy link

gbikram commented May 16, 2025

Description

Connector Name: MISP
URL: https://github.com/OpenCTI-Platform/connectors/tree/master/external-import/misp

  • Lines 621-640 assume that event["Event"]["distribution"] and event["Event"]["threat_level_id"] will be of type str always.
  • However, certain MISP servers return these attributes as int type.
  • This leads to incorrect results from the comparison operations carried out on lines 621 and 631 (always True).
  • Additionally, the log_info operations within the comparisons result in exceptions due to incorrect types being concatenated (str + int).

Expected Output

In case a MISP server returns the above properties as int, the connector should convert them to str.

Actual Output

Exception is raised due to incorrect types being concatenated.

Proposed Fix

Cast event["Event"]["distribution"] and event["Event"]["threat_level_id"] within str:

if (
    import_distribution_levels is not None
    and str(event["Event"]["distribution"]) not in import_distribution_levels       # FIX:Cast as str
):
    self.helper.log_info(
        "Event distribution level "
        + str(event["Event"]["distribution"])                                       # FIX:Cast as str
        + " not in import_distribution_levels, do not import"
    )
    continue
if (
    import_threat_levels is not None
    and str(event["Event"]["threat_level_id"]) not in import_threat_levels          # FIX:Cast as str
):
    self.helper.log_info(
        "Event threat level "
        + str(event["Event"]["threat_level_id"])                                    # FIX:Cast as str
        + " not in import_threat_levels, do not import"
    )
    continue
@gbikram gbikram added bug use for describing something not working as expected needs triage use to identify issue needing triage from Filigran Product team labels May 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug use for describing something not working as expected needs triage use to identify issue needing triage from Filigran Product team
Projects
None yet
Development

No branches or pull requests

1 participant