Sha256: c436c58c2c737aab94eff3635c051e8025504a155d4bfcaa6b3769e619c56b1c

Contents?: true

Size: 970 Bytes

Versions: 16

Compression:

Stored size: 970 Bytes

Contents

module Dradis::Plugins::ContentService
  module Evidence
    extend ActiveSupport::Concern

    def create_evidence(args={})
      content = args.fetch(:content, default_evidence_content)
      node    = args.fetch(:node, default_node_parent)
      issue   = args[:issue] || default_evidence_issue

      evidence = node.evidence.new(issue_id: issue.id, content: content)

      if evidence.valid?
        evidence.save
      else
        try_rescue_from_length_validation(
          model: evidence,
          field: :content,
          text: content,
          msg: 'Error in create_evidence()'
        )
      end

      evidence
    end

    private

    def default_evidence_content
      "create_evidence() invoked by #{plugin} without a :content parameter"
    end

    def default_evidence_issue
      create_issue(text: "#[Title]#\nAuto-generated issue.\n\n#[Description]#\ncreate_evidence() invoked by #{plugin} without an :issue parameter")
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
dradis-plugins-3.21.0 lib/dradis/plugins/content_service/evidence.rb
dradis-plugins-3.20.0 lib/dradis/plugins/content_service/evidence.rb
dradis-plugins-3.19.0 lib/dradis/plugins/content_service/evidence.rb
dradis-plugins-3.18.0 lib/dradis/plugins/content_service/evidence.rb
dradis-plugins-3.17.0 lib/dradis/plugins/content_service/evidence.rb
dradis-plugins-3.16.0 lib/dradis/plugins/content_service/evidence.rb
dradis-plugins-3.15.0 lib/dradis/plugins/content_service/evidence.rb
dradis-plugins-3.14.0 lib/dradis/plugins/content_service/evidence.rb
dradis-plugins-3.13.0 lib/dradis/plugins/content_service/evidence.rb
dradis-plugins-3.12.0 lib/dradis/plugins/content_service/evidence.rb
dradis-plugins-3.11.0 lib/dradis/plugins/content_service/evidence.rb
dradis-plugins-3.10.0 lib/dradis/plugins/content_service/evidence.rb
dradis-plugins-3.9.0 lib/dradis/plugins/content_service/evidence.rb
dradis-plugins-3.8.0 lib/dradis/plugins/content_service/evidence.rb
dradis-plugins-3.7.0 lib/dradis/plugins/content_service/evidence.rb
dradis-plugins-3.6.0 lib/dradis/plugins/content_service/evidence.rb