Skip to content

Commit 9de9bf7

Browse files
committed
Merge branch 'stages/rc-2025-03-11' into 'stages/prod'
Deploy RC 88 to Prod See merge request lg/identity-pki!77
2 parents f4a55bf + 21237cd commit 9de9bf7

File tree

4 files changed

+44
-36
lines changed

4 files changed

+44
-36
lines changed

.gitlab-ci.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,49 @@ check_expiring_certificates:
141141
- bundle exec rake db:setup --trace
142142
- bundle exec rake certs:print_expiring[0]
143143

144+
145+
include:
146+
- template: Security/Secret-Detection.gitlab-ci.yml
147+
148+
secret_detection:
149+
stage: test
150+
allow_failure: false
151+
needs: []
152+
artifacts:
153+
paths:
154+
- gl-secret-detection-report.json
155+
reports:
156+
secret_detection: gl-secret-detection-report.json
157+
variables:
158+
SECRET_DETECTION_EXCLUDED_PATHS: 'keys.example,config/artifacts.example,public/acuant/*/opencv.min.js,tmp/0.0.0.0-3000.key'
159+
SECRET_DETECTION_REPORT_FILE: 'gl-secret-detection-report.json'
160+
rules:
161+
- if: $SECRET_DETECTION_DISABLED
162+
when: never
163+
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
164+
- if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
165+
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
166+
variables:
167+
SECRET_DETECTION_LOG_OPTIONS: ${CI_MERGE_REQUEST_DIFF_BASE_SHA}..${CI_COMMIT_SHA}
168+
before_script:
169+
- apk add --no-cache jq
170+
script:
171+
- |
172+
echo "running analyzer"
173+
/analyzer run
174+
if [ -f "$SECRET_DETECTION_REPORT_FILE" ]; then
175+
# check if '{ "vulnerabilities": [], ..' is empty in the report file if it exists
176+
if [ "$(jq ".vulnerabilities | length" $SECRET_DETECTION_REPORT_FILE)" -gt 0 ]; then
177+
echo "Vulnerabilities detected. Please analyze the artifact $SECRET_DETECTION_REPORT_FILE produced by the 'secret-detection' job."
178+
echo "Check the \"Security\" tab on the overall pipeline run to download the report for more information."
179+
exit 1
180+
fi
181+
else
182+
echo "Artifact $SECRET_DETECTION_REPORT_FILE does not exist. The 'secret-detection' job likely didn't create one. Hence, no evaluation can be performed."
183+
fi
184+
185+
186+
144187
build-ci-image:
145188
stage: build
146189
interruptible: true

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ GEM
229229
puma (6.4.3)
230230
nio4r (~> 2.0)
231231
racc (1.8.1)
232-
rack (3.1.10)
232+
rack (3.1.12)
233233
rack-session (2.0.0)
234234
rack (>= 3.0.0)
235235
rack-test (2.1.0)

app/controllers/identify_controller.rb

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
require 'cgi'
2-
require 'openssl'
32
require 'open3'
43

54
class IdentifyController < ApplicationController
@@ -104,8 +103,6 @@ def allowed_referrer?(uri)
104103
def log_certificate(cert)
105104
validation_result = cert.validate_cert(is_leaf: true)
106105
valid = validation_result == 'valid'
107-
login_certs_openssl_result = openssl_validate(cert.to_pem, Rails.root.join(IdentityConfig.store.login_certificate_bundle_file).to_s)
108-
ficam_certs_openssl_result = openssl_validate(cert.to_pem, Rails.root.join(IdentityConfig.store.ficam_certificate_bundle_file).to_s)
109106
attributes = {
110107
name: 'Certificate Processed',
111108
signing_key_id: cert.signing_key_id,
@@ -116,35 +113,13 @@ def log_certificate(cert)
116113
mapped_policy_oids: cert.mapped_policies.map { |oid| [oid, true] }.to_h,
117114
valid: valid,
118115
error: !valid ? validation_result : nil,
119-
openssl_valid: login_certs_openssl_result[:valid],
120-
openssl_errors: login_certs_openssl_result[:errors],
121-
ficam_openssl_valid: ficam_certs_openssl_result[:valid],
122-
ficam_openssl_errors: ficam_certs_openssl_result[:errors],
123116
}
124117

125118
attributes.delete(:issuer) if validation_result == 'self-signed cert'
126119
if valid
127120
attributes[:matched_policy_oids] = cert.matched_policy_oids.map { |oid| [oid, true] }.to_h
128121
end
129122

130-
# Log certificate if it fails either OpenSSL validation, but passes our current validation or vice versa
131-
if valid != login_certs_openssl_result[:valid] || valid != ficam_certs_openssl_result[:valid]
132-
CertificateLoggerService.log_certificate(cert)
133-
end
134-
135123
logger.info(attributes.to_json)
136124
end
137-
138-
def openssl_validate(certificate_pem, certificate_bundle_file_path)
139-
return {} if !IdentityConfig.store.openssl_verify_enabled
140-
stdout, stderr, status = Open3.capture3('openssl', 'verify', '-purpose', 'sslclient', '-inhibit_any', '-explicit_policy', '-CAfile', certificate_bundle_file_path, '-policy_check', '-policy', '2.16.840.1.101.3.2.1.3.7', '-policy', '2.16.840.1.101.3.2.1.3.13', '-policy', '2.16.840.1.101.3.2.1.3.15', '-policy', '2.16.840.1.101.3.2.1.3.16', '-policy', '2.16.840.1.101.3.2.1.3.18', '-policy', '2.16.840.1.101.3.2.1.3.41', stdin_data: certificate_pem)
141-
142-
stderr.strip!
143-
stdout.strip!
144-
errors = stderr.scan(/(error \d+ [\w :]+)$\n?/).flatten
145-
{
146-
valid: status.success? && stdout.ends_with?('OK') && errors.empty?,
147-
errors: errors.join(', '),
148-
}
149-
end
150125
end

spec/controllers/identify_controller_spec.rb

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@
140140

141141
cert = Certificate.new(client_cert)
142142

143-
expect(CertificateLoggerService).to receive(:log_certificate).once
144143
expect(Rails.logger).to receive(:info).with(/GET/).once
145144
expect(Rails.logger).to receive(:info).with(
146145
'Returning a token for a valid certificate.'
@@ -155,10 +154,6 @@
155154
mapped_policy_oids: { '2.16.840.1.101.3.2.1.3.7' => true },
156155
valid: true,
157156
error: nil,
158-
openssl_valid: false,
159-
openssl_errors: 'error 20 at 0 depth lookup: unable to get local issuer certificate',
160-
ficam_openssl_valid: false,
161-
ficam_openssl_errors: 'error 20 at 0 depth lookup: unable to get local issuer certificate',
162157
matched_policy_oids: { '2.16.840.1.101.3.2.1.3.7' => true },
163158
}.to_json).once
164159

@@ -209,7 +204,6 @@
209204
it 'returns a token with a uuid and subject' do
210205
allow(IdentityConfig.store).to receive(:client_cert_escaped).and_return(false)
211206
@request.headers['X-Client-Cert'] = client_cert_pem.split(/\n/).join("\n\t")
212-
expect(CertificateLoggerService).to receive(:log_certificate).once
213207

214208
get :create, params: { nonce: '123', redirect_uri: 'http://example.com/' }
215209
expect(response).to have_http_status(:found)
@@ -372,10 +366,6 @@
372366
mapped_policy_oids: {},
373367
valid: false,
374368
error: 'self-signed cert',
375-
openssl_valid: false,
376-
openssl_errors: 'error 18 at 0 depth lookup: self signed certificate, error 26 at 0 depth lookup: unsupported certificate purpose',
377-
ficam_openssl_valid: false,
378-
ficam_openssl_errors: 'error 18 at 0 depth lookup: self signed certificate, error 26 at 0 depth lookup: unsupported certificate purpose',
379369
}.to_json).once
380370

381371
get :create, params: { nonce: '123', redirect_uri: 'http://example.com/' }

0 commit comments

Comments
 (0)