Skip to content

Commit

Permalink
Update snyk_v2_task.rb
Browse files Browse the repository at this point in the history
updating task to avoid possible duplicated values
  • Loading branch information
jesutorrr committed May 30, 2024
1 parent 54da0fc commit 86840d6
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions tasks/connectors/snyk_v2/snyk_v2_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ def run(opts)
print_debug "issue json = #{issue_json}"
end

unique_issues = {}
unique_vuln_defs = {}

issue_json.each do |issue_arr|
issue_arr.each do |issue_obj|
issue = issue_obj["attributes"]
Expand Down Expand Up @@ -169,9 +172,18 @@ def run(opts)
"solution" => issue["resolution"] ? issue["resolution"]["details"] : nil
}.compact

batch.append do
create_kdi_asset_vuln(asset, kdi_issue)
create_kdi_vuln_def(vuln_def)
unless unique_issues[scanner_identifier]
unique_issues[scanner_identifier] = true
batch.append do
create_kdi_asset_vuln(asset, kdi_issue)
end
end

unless unique_vuln_defs[vuln_def_name]
unique_vuln_defs[vuln_def_name] = true
batch.append do
create_kdi_vuln_def(vuln_def)
end
end
end
end
Expand Down

0 comments on commit 86840d6

Please sign in to comment.