Skip to content

Add all_evidence to content service and cascade upload state to Evidence - #127

Open
caitmich wants to merge 9 commits into
mainfrom
feature/evidence-content-service-scope
Open

Add all_evidence to content service and cascade upload state to Evidence#127
caitmich wants to merge 9 commits into
mainfrom
feature/evidence-content-service-scope

Conversation

@caitmich

@caitmich caitmich commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds Dradis::Plugins::ContentService::Evidence#all_evidence, mirroring the existing Issues#all_issues and ContentBlocks#all_content_blocks:
def all_evidence
  case scope
  when :all
    project.evidence
  when :published
    project.evidence.published
  else
    raise 'Unsupported scope!'
  end
end

This lets export plugins fetch Evidence already scoped to the export's :published/:all scope, the same way they already do for Issues and Content Blocks, instead of re-querying node.evidence/issue.evidence themselves inside export processors.

  • Also fixes create_evidence so it cascades the upload's chosen :state to newly created Evidence records, matching create_issue's existing behaviour

(Needed by the Word & Excel export PRs (dradis-pro#2938, dradis-pro#2951) and by html_export/csv_export (#99, #57), all of which fetch all_evidence once per export and group/filter it in memory per Issue rather than re-querying per Issue. Evidence's independent published/draft/ready_for_review review state was added in dradis-ce/dradis-pro branch qa/add-evidence-review-state; this PR requires Evidence#published (a Rails enum scope), which that branch adds, to exist on the host app's Evidence model.)

Testing Steps

From the Dradis Pro app directory, with this gem checked out at a sibling path, temporarily point the Gemfile at this branch/path and run:

bin/rspec [dradis-plugins path]/spec/lib/dradis/plugins/content_service/evidence_spec.rb

Assert all examples pass, confirming: all_evidence returns only published evidence by default and all evidence when scope is :all; create_evidence sets the new record's state from the :state argument (or the service's default state when none is given); and re-uploading matching content does not change an existing evidence record's state.

Other Information

Once merged, this needs a version bump + gem release, and the dependent PRs above need their temporary local path/branch overrides in the Gemfile switched to the released version.

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

Check List

  • Added a CHANGELOG entry
  • Added specs

@caitmich caitmich changed the title Add all_evidence to the content service, scoped by published/all Add all_evidence to the content service and cascade upload state to Evidence Aug 25, 2026
@caitmich caitmich changed the title Add all_evidence to the content service and cascade upload state to Evidence Add all_evidence to content service and cascade upload state to Evidence Aug 25, 2026
Comment thread lib/dradis/plugins/content_service/evidence.rb Outdated
Comment thread lib/dradis/plugins/content_service/evidence.rb
…eady exists and memoize evidence_for per issue, keeping it an AR relation instead of loading all evidence upfront
Comment thread lib/dradis/plugins/content_service/evidence.rb Outdated
Comment thread lib/dradis/plugins/content_service/evidence.rb Outdated
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.

3 participants