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

Graph creation - update USES relationships for content items that contains alert in the name #4787

Open
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

adi88d
Copy link
Contributor

@adi88d adi88d commented Jan 27, 2025

Related Issues

fixes:
https://jira-dc.paloaltonetworks.com/browse/CIAC-7711
https://jira-dc.paloaltonetworks.com/browse/CIAC-11954

Description

Added a new query to run in the end of create_relationships to update USES relationships that meet the following conditions:

  • Source node contains alert in the object_id.
  • Source node not_in_repository=true.
  • Source node is in marketplacev2 but not in xsoar marketplaces.

We updated the target node that meet the following conditions:

  • Target object_id with incident instead alert (for example searchAlerts in XSIAM -> searchIncidents in xsoar).
  • Target is in repository.
  • The content type is similar to the old target.
  • Target node is in marketplacev2 and in xsoar marketplaces.

The update_alert_to_incident_relationships method replaced the target in the relationship when all of these conditions are met.

Copy link

Changelog(s) in markdown:

  • Fixed an issue where GR103 falsely failed when content items contains the word 'alert' in XSIAM. #4785

@adi88d adi88d marked this pull request as ready for review January 28, 2025 12:49
@adi88d adi88d requested a review from dantavori January 28, 2025 12:49
@adi88d adi88d changed the title verify alert to incident for gr103 GR103 validation - fixed false-negatives results for XSIAM for content items with the word alert Jan 28, 2025
@adi88d adi88d changed the title GR103 validation - fixed false-negatives results for XSIAM for content items with the word alert GR103 validation - Fixed false-negatives results for XSIAM for content items with the word alert Jan 28, 2025
@adi88d adi88d changed the title GR103 validation - Fixed false-negatives results for XSIAM for content items with the word alert Graph creation - update USES relationships for content items that contains alert in the name Feb 20, 2025
Copy link
Contributor

@RosenbergYehuda RosenbergYehuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very Nice!
Please see my comments.
In addition, I wonder if chat gpt can improve the query to look better...

@@ -0,0 +1,4 @@
changes:
- description: Fixed an issue in graph creation where the content items in XSIAM replaced the word 'alert' with 'incident' on upload.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed an issue where, when creating relationships between nodes, if the target is not in the repository due to a naming convention (e.g., "incident" to "alert"), the incorrect relationship is deleted and a correct one is created.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -109,6 +109,41 @@ def build_uses_relationships_query(
RETURN count(r) AS relationships_merged"""


def update_alert_to_incident_relationships():
return f"""
// Updated USES relationships between nodes when the source contains "alert" in the id,
Copy link
Contributor

@RosenbergYehuda RosenbergYehuda Feb 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Update USES relationships when the source node contains "alert" in its ID.
// This query addresses a scenario where relationships are created in our repository
// to items that do not yet exist with the expected names. Since we know the item names
// will be adjusted during upload (e.g., "incident" might be declared as "alert" in the marketplace),
// we initially use the "expected" name (e.g., "alert"). This discrepancy causes a false "not_in_repository" flag.
// The query ensures that the target node is updated to the correct item in the repository,
// replacing "alert" with "incident" to align with the correct naming convention,
// resolving the false flag and maintaining accurate relationships.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated



// delete the old target node and old relationship
DELETE r
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't deleting the target enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it failed and ask to delete the relationship before

@adi88d
Copy link
Contributor Author

adi88d commented Feb 26, 2025

Very Nice! Please see my comments. In addition, I wonder if chat gpt can improve the query to look better...

what I wrote in the code its after chat gpt improvements

Copy link

Changelog(s) in markdown:

  • Fixed an issue where, when creating relationships between nodes, if the target is not in the repository due to a naming convention (e.g., "incident" to "alert"), the incorrect relationship is deleted and a correct one is created. #4785

@RosenbergYehuda RosenbergYehuda self-requested a review February 27, 2025 08:06
Copy link
Contributor

@RosenbergYehuda RosenbergYehuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants