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

Update evidence screenshot links after node merge #1291

Open
wants to merge 2 commits into
base: nodes-merge/table-caching
Choose a base branch
from

Conversation

caitmich
Copy link
Contributor

@caitmich caitmich commented Sep 4, 2024

Summary

After merging nodes, screenshots in the Evidence content are left pointing to the old node. The attachments are copied over but the links are not updated. This means users face validation errors and have to manually update all screenshot references after merging nodes.

I assign all rights, including copyright, to any future Dradis
work by myself to Security Roots.

Check List

  • Added a CHANGELOG entry

@caitmich caitmich changed the base branch from develop to nodes-merge/table-caching September 4, 2024 15:12
Comment on lines +105 to +106
target_node.evidence_ids.each do |evidence_id|
evidence = Evidence.find(evidence_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

What about

Suggested change
target_node.evidence_ids.each do |evidence_id|
evidence = Evidence.find(evidence_id)
target_node.evidence.each do |evidence|

@@ -90,15 +92,33 @@ def update_properties
end

def copy_attachments
Copy link
Contributor

Choose a reason for hiding this comment

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

This class is including the AttachmentsCopier that defines a copy_attachments method but this also defines a method with the same name. Should we differentiate the 2 and use a different name?

end
end
end

def updated_record_content(record_content, full_screenshot_path, new_attachment)
Copy link
Contributor

Choose a reason for hiding this comment

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

updated_record_content doesn't quite describe what this method does. What about update_attachment_link or update_attachment_reference, or something else?

def update_attachment_references
target_node.evidence_ids.each do |evidence_id|
evidence = Evidence.find(evidence_id)
evidence.content.scan(Attachment::SCREENSHOT_REGEX).each do |screenshot_path|
Copy link
Contributor

Choose a reason for hiding this comment

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

This is very similar to the AttachmentsCopier#copy_attachments method. Is there something we can reuse from there?

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