Commit 43929786 authored by Alex Kalderimis's avatar Alex Kalderimis

Merge branch 'token_revoke_public_project' into 'master'

Allow token revocation for public projects only

See merge request gitlab-org/gitlab!53734
parents 4ab7d7f8 c1c257d9
...@@ -27,6 +27,7 @@ class StoreSecurityReportsWorker # rubocop:disable Scalability/IdempotentWorker ...@@ -27,6 +27,7 @@ class StoreSecurityReportsWorker # rubocop:disable Scalability/IdempotentWorker
def revoke_secret_detection_token?(pipeline) def revoke_secret_detection_token?(pipeline)
pipeline.present? && pipeline.present? &&
pipeline.project.public? &&
::Gitlab::CurrentSettings.secret_detection_token_revocation_enabled? && ::Gitlab::CurrentSettings.secret_detection_token_revocation_enabled? &&
secret_detection_vulnerability_found?(pipeline) secret_detection_vulnerability_found?(pipeline)
end end
......
---
title: Allow token revocation for public projects only
merge_request: 53734
author:
type: changed
...@@ -18,18 +18,17 @@ RSpec.describe StoreSecurityReportsWorker do ...@@ -18,18 +18,17 @@ RSpec.describe StoreSecurityReportsWorker do
describe '#revoke_secret_detection_token?' do describe '#revoke_secret_detection_token?' do
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
where(:pipeline, :token_revocation_enabled, :secret_detection_vulnerability_found, :expected_result) do where(:visibility, :token_revocation_enabled, :secret_detection_vulnerability_found) do
Object.new | true | true | true booleans = [true, true, false, false].permutation(2).to_a.uniq
Object.new | true | false | false [:public, :private, nil].flat_map do |vis|
Object.new | false | true | false booleans.map { |bools| [vis, *bools] }
Object.new | false | false | false end
nil | true | true | false
nil | true | false | false
nil | false | true | false
nil | false | false | false
end end
with_them do with_them do
let(:pipeline) { build(:ci_pipeline, project: build(:project, :repository, visibility)) if visibility }
let(:expected_result) { [visibility, token_revocation_enabled, secret_detection_vulnerability_found] == [:public, true, true] }
before do before do
stub_application_setting(secret_detection_token_revocation_enabled: token_revocation_enabled) stub_application_setting(secret_detection_token_revocation_enabled: token_revocation_enabled)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment