diff --git a/ee/app/models/ee/vulnerability.rb b/ee/app/models/ee/vulnerability.rb index ab6e4baf706bdc88b2e2f49fa3acce8e3ed84448..b48295e8a7d5a1776096122da8a0d79ac77d58fc 100644 --- a/ee/app/models/ee/vulnerability.rb +++ b/ee/app/models/ee/vulnerability.rb @@ -230,7 +230,8 @@ def latest_state_transition def send_to_ai? ::Feature.enabled?(:explain_vulnerability, project) && - finding&.ai_explainable? + finding.present? && + !secret_detection? end private diff --git a/ee/app/models/vulnerabilities/finding.rb b/ee/app/models/vulnerabilities/finding.rb index 29806f096ef40405ae198c898c160d6b2b150572..30d38d8266cc678458bba987acd2c4c297530a50 100644 --- a/ee/app/models/vulnerabilities/finding.rb +++ b/ee/app/models/vulnerabilities/finding.rb @@ -410,10 +410,6 @@ def last_finding_pipeline finding_pipelines.last&.pipeline end - def ai_explainable? - file.present? && location["start_line"].present? - end - protected def primary_identifier_fingerprint diff --git a/ee/lib/gitlab/llm/open_ai/templates/explain_vulnerability.rb b/ee/lib/gitlab/llm/open_ai/templates/explain_vulnerability.rb index d04055bfad3d33b71e97153261585391fa41e540..3a8a61cb715617ed2242d0f74e997a6f5c6f4cca 100644 --- a/ee/lib/gitlab/llm/open_ai/templates/explain_vulnerability.rb +++ b/ee/lib/gitlab/llm/open_ai/templates/explain_vulnerability.rb @@ -13,7 +13,7 @@ def initialize(vulnerability) def options { - max_tokens: ::Llm::ExplainCodeService::MAX_RESPONSE_TOKENS + max_tokens: 3_000 } end diff --git a/ee/spec/models/ee/vulnerability_spec.rb b/ee/spec/models/ee/vulnerability_spec.rb index 01c895955c60ed935a6ade2a692b0e6ce2c45b00..5958a2067d91d840d0c47657f3ecfb7268bfbfe5 100644 --- a/ee/spec/models/ee/vulnerability_spec.rb +++ b/ee/spec/models/ee/vulnerability_spec.rb @@ -954,6 +954,12 @@ it { expect(vulnerability).to be_send_to_ai } end + context 'when the vulnerability is for a Secret Detection' do + let_it_be(:vulnerability) { create(:vulnerability, :secret_detection, :with_finding) } + + it { expect(vulnerability).not_to be_send_to_ai } + end + context 'when the vulnerability does not include a file' do let_it_be(:vulnerability) { create(:vulnerability, :with_finding) } @@ -961,7 +967,7 @@ vulnerability.finding.location.delete('file') end - it { expect(vulnerability).not_to be_send_to_ai } + it { expect(vulnerability).to be_send_to_ai } end context 'when the vulnerability does not include a start line' do @@ -971,7 +977,7 @@ vulnerability.finding.location.delete('start_line') end - it { expect(vulnerability).not_to be_send_to_ai } + it { expect(vulnerability).to be_send_to_ai } end context 'when the vulnerability does not include a finding' do