Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2020-08-26 21:10:19 +00:00
parent bc75527dca
commit ed98ffb618
13 changed files with 287 additions and 22 deletions

View File

@ -35,7 +35,7 @@
%td
- if token.expires?
- if token.expires_at.past? || token.expires_at.today?
%span{ class: 'text-danger has-tooltip', title: _('Expiration not enforced') }
%span{ class: 'text-danger has-tooltip', title: _('Token valid until revoked') }
= _('Expired')
- else
%span{ class: ('text-warning' if token.expires_soon?) }

View File

@ -0,0 +1,5 @@
---
title: Create IssueLink for Vulnerabilities that do not have them
merge_request: 39986
author:
type: fixed

View File

@ -0,0 +1,5 @@
---
title: Add dedicated SAST and DS CI image variables
merge_request: 39875
author:
type: added

View File

@ -327,6 +327,8 @@ module.exports = {
chunks: false,
modules: false,
assets: true,
errors: !IS_PRODUCTION,
warnings: !IS_PRODUCTION,
});
// tell our rails helper where to find the DLL files

View File

@ -0,0 +1,19 @@
# frozen_string_literal: true
class CreateIndexVulnerabilitiesFeedbackIssueIdNotNull < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :vulnerability_feedback, :id, where: 'issue_id IS NOT NULL',
name: "index_vulnerability_feedback_on_issue_id_not_null"
end
def down
remove_concurrent_index_by_name :vulnerability_feedback,
:index_vulnerability_feedback_on_issue_id_not_null
end
end

View File

@ -0,0 +1,49 @@
# frozen_string_literal: true
class CreateMissingVulnerabilitiesIssueLinks < ActiveRecord::Migration[6.0]
class VulnerabilitiesFeedback < ActiveRecord::Base
include EachBatch
self.table_name = 'vulnerability_feedback'
end
class VulnerabilitiesIssueLink < ActiveRecord::Base
self.table_name = 'vulnerability_issue_links'
LINK_TYPE_CREATED = 2
end
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
VulnerabilitiesFeedback.where('issue_id IS NOT NULL').each_batch do |relation|
timestamp = Time.now
issue_links = relation
.joins("JOIN vulnerability_occurrences vo ON vo.project_id = vulnerability_feedback.project_id AND vo.report_type = vulnerability_feedback.category AND encode(vo.project_fingerprint, 'hex') = vulnerability_feedback.project_fingerprint")
.where('vo.vulnerability_id IS NOT NULL')
.pluck(:vulnerability_id, :issue_id)
.map do |v_id, i_id|
{
vulnerability_id: v_id,
issue_id: i_id,
link_type: VulnerabilitiesIssueLink::LINK_TYPE_CREATED,
created_at: timestamp,
updated_at: timestamp
}
end
next if issue_links.empty?
VulnerabilitiesIssueLink.insert_all(
issue_links,
returning: false,
unique_by: %i[vulnerability_id issue_id]
)
end
end
def down
end
end

View File

@ -0,0 +1 @@
36d3db5618a56a0ea03272563fe254590d6af1f7d2610a1f01a5054b1cda1a7d

View File

@ -0,0 +1 @@
e8fc0809b5bd3248dc625602deeaaef16e2db6b33d8eaf51fdcc1c67dee49e17

View File

@ -21007,6 +21007,8 @@ CREATE INDEX index_vulnerability_feedback_on_comment_author_id ON public.vulnera
CREATE INDEX index_vulnerability_feedback_on_issue_id ON public.vulnerability_feedback USING btree (issue_id);
CREATE INDEX index_vulnerability_feedback_on_issue_id_not_null ON public.vulnerability_feedback USING btree (id) WHERE (issue_id IS NOT NULL);
CREATE INDEX index_vulnerability_feedback_on_merge_request_id ON public.vulnerability_feedback USING btree (merge_request_id);
CREATE INDEX index_vulnerability_feedback_on_pipeline_id ON public.vulnerability_feedback USING btree (pipeline_id);

View File

@ -96,7 +96,9 @@ dependency_scanning:
gemnasium-dependency_scanning:
extends: .ds-analyzer
image:
name: "$SECURE_ANALYZERS_PREFIX/gemnasium:$DS_MAJOR_VERSION"
name: "$DS_ANALYZER_IMAGE"
variables:
DS_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/gemnasium:$DS_MAJOR_VERSION"
rules:
- if: $DEPENDENCY_SCANNING_DISABLED || $DS_DISABLE_DIND == 'false'
when: never
@ -116,7 +118,9 @@ gemnasium-dependency_scanning:
gemnasium-maven-dependency_scanning:
extends: .ds-analyzer
image:
name: "$SECURE_ANALYZERS_PREFIX/gemnasium-maven:$DS_MAJOR_VERSION"
name: "$DS_ANALYZER_IMAGE"
variables:
DS_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/gemnasium-maven:$DS_MAJOR_VERSION"
rules:
- if: $DEPENDENCY_SCANNING_DISABLED || $DS_DISABLE_DIND == 'false'
when: never
@ -132,7 +136,9 @@ gemnasium-maven-dependency_scanning:
gemnasium-python-dependency_scanning:
extends: .ds-analyzer
image:
name: "$SECURE_ANALYZERS_PREFIX/gemnasium-python:$DS_MAJOR_VERSION"
name: "$DS_ANALYZER_IMAGE"
variables:
DS_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/gemnasium-python:$DS_MAJOR_VERSION"
rules:
- if: $DEPENDENCY_SCANNING_DISABLED || $DS_DISABLE_DIND == 'false'
when: never
@ -155,7 +161,9 @@ gemnasium-python-dependency_scanning:
bundler-audit-dependency_scanning:
extends: .ds-analyzer
image:
name: "$SECURE_ANALYZERS_PREFIX/bundler-audit:$DS_MAJOR_VERSION"
name: "$DS_ANALYZER_IMAGE"
variables:
DS_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/bundler-audit:$DS_MAJOR_VERSION"
rules:
- if: $DEPENDENCY_SCANNING_DISABLED || $DS_DISABLE_DIND == 'false'
when: never
@ -168,7 +176,9 @@ bundler-audit-dependency_scanning:
retire-js-dependency_scanning:
extends: .ds-analyzer
image:
name: "$SECURE_ANALYZERS_PREFIX/retire.js:$DS_MAJOR_VERSION"
name: "$DS_ANALYZER_IMAGE"
variables:
DS_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/retire.js:$DS_MAJOR_VERSION"
rules:
- if: $DEPENDENCY_SCANNING_DISABLED || $DS_DISABLE_DIND == 'false'
when: never

View File

@ -59,7 +59,9 @@ sast:
bandit-sast:
extends: .sast-analyzer
image:
name: "$SECURE_ANALYZERS_PREFIX/bandit:$SAST_ANALYZER_IMAGE_TAG"
name: "SAST_ANALYZER_IMAGE"
variables:
SAST_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/bandit:$SAST_ANALYZER_IMAGE_TAG"
rules:
- if: $SAST_DISABLED || $SAST_DISABLE_DIND == 'false'
when: never
@ -71,7 +73,9 @@ bandit-sast:
brakeman-sast:
extends: .sast-analyzer
image:
name: "$SECURE_ANALYZERS_PREFIX/brakeman:$SAST_ANALYZER_IMAGE_TAG"
name: "SAST_ANALYZER_IMAGE"
variables:
SAST_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/brakeman:$SAST_ANALYZER_IMAGE_TAG"
rules:
- if: $SAST_DISABLED || $SAST_DISABLE_DIND == 'false'
when: never
@ -83,7 +87,9 @@ brakeman-sast:
eslint-sast:
extends: .sast-analyzer
image:
name: "$SECURE_ANALYZERS_PREFIX/eslint:$SAST_ANALYZER_IMAGE_TAG"
name: "$SAST_ANALYZER_IMAGE"
variables:
SAST_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/eslint:$SAST_ANALYZER_IMAGE_TAG"
rules:
- if: $SAST_DISABLED || $SAST_DISABLE_DIND == 'false'
when: never
@ -99,7 +105,9 @@ eslint-sast:
flawfinder-sast:
extends: .sast-analyzer
image:
name: "$SECURE_ANALYZERS_PREFIX/flawfinder:$SAST_ANALYZER_IMAGE_TAG"
name: "SAST_ANALYZER_IMAGE"
variables:
SAST_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/flawfinder:$SAST_ANALYZER_IMAGE_TAG"
rules:
- if: $SAST_DISABLED || $SAST_DISABLE_DIND == 'false'
when: never
@ -112,7 +120,9 @@ flawfinder-sast:
kubesec-sast:
extends: .sast-analyzer
image:
name: "$SECURE_ANALYZERS_PREFIX/kubesec:$SAST_ANALYZER_IMAGE_TAG"
name: "$SAST_ANALYZER_IMAGE"
variables:
SAST_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/kubesec:$SAST_ANALYZER_IMAGE_TAG"
rules:
- if: $SAST_DISABLED || $SAST_DISABLE_DIND == 'false'
when: never
@ -123,7 +133,9 @@ kubesec-sast:
gosec-sast:
extends: .sast-analyzer
image:
name: "$SECURE_ANALYZERS_PREFIX/gosec:$SAST_ANALYZER_IMAGE_TAG"
name: "$SAST_ANALYZER_IMAGE"
variables:
SAST_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/gosec:$SAST_ANALYZER_IMAGE_TAG"
rules:
- if: $SAST_DISABLED || $SAST_DISABLE_DIND == 'false'
when: never
@ -135,7 +147,9 @@ gosec-sast:
nodejs-scan-sast:
extends: .sast-analyzer
image:
name: "$SECURE_ANALYZERS_PREFIX/nodejs-scan:$SAST_ANALYZER_IMAGE_TAG"
name: "$SAST_ANALYZER_IMAGE"
variables:
SAST_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/nodejs-scan:$SAST_ANALYZER_IMAGE_TAG"
rules:
- if: $SAST_DISABLED || $SAST_DISABLE_DIND == 'false'
when: never
@ -147,7 +161,9 @@ nodejs-scan-sast:
phpcs-security-audit-sast:
extends: .sast-analyzer
image:
name: "$SECURE_ANALYZERS_PREFIX/phpcs-security-audit:$SAST_ANALYZER_IMAGE_TAG"
name: "$SAST_ANALYZER_IMAGE"
variables:
SAST_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/phpcs-security-audit:$SAST_ANALYZER_IMAGE_TAG"
rules:
- if: $SAST_DISABLED || $SAST_DISABLE_DIND == 'false'
when: never
@ -159,7 +175,9 @@ phpcs-security-audit-sast:
pmd-apex-sast:
extends: .sast-analyzer
image:
name: "$SECURE_ANALYZERS_PREFIX/pmd-apex:$SAST_ANALYZER_IMAGE_TAG"
name: "$SAST_ANALYZER_IMAGE"
variables:
SAST_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/pmd-apex:$SAST_ANALYZER_IMAGE_TAG"
rules:
- if: $SAST_DISABLED || $SAST_DISABLE_DIND == 'false'
when: never
@ -171,7 +189,9 @@ pmd-apex-sast:
secrets-sast:
extends: .sast-analyzer
image:
name: "$SECURE_ANALYZERS_PREFIX/secrets:$SAST_ANALYZER_IMAGE_TAG"
name: "$SAST_ANALYZER_IMAGE"
variables:
SAST_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/secrets:$SAST_ANALYZER_IMAGE_TAG"
rules:
- if: $SAST_DISABLED || $SAST_DISABLE_DIND == 'false'
when: never
@ -181,7 +201,9 @@ secrets-sast:
security-code-scan-sast:
extends: .sast-analyzer
image:
name: "$SECURE_ANALYZERS_PREFIX/security-code-scan:$SAST_ANALYZER_IMAGE_TAG"
name: "$SAST_ANALYZER_IMAGE"
variables:
SAST_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/security-code-scan:$SAST_ANALYZER_IMAGE_TAG"
rules:
- if: $SAST_DISABLED || $SAST_DISABLE_DIND == 'false'
when: never
@ -194,7 +216,9 @@ security-code-scan-sast:
sobelow-sast:
extends: .sast-analyzer
image:
name: "$SECURE_ANALYZERS_PREFIX/sobelow:$SAST_ANALYZER_IMAGE_TAG"
name: "$SAST_ANALYZER_IMAGE"
variables:
SAST_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/sobelow:$SAST_ANALYZER_IMAGE_TAG"
rules:
- if: $SAST_DISABLED || $SAST_DISABLE_DIND == 'false'
when: never
@ -206,7 +230,9 @@ sobelow-sast:
spotbugs-sast:
extends: .sast-analyzer
image:
name: "$SECURE_ANALYZERS_PREFIX/spotbugs:$SAST_ANALYZER_IMAGE_TAG"
name: "$SAST_ANALYZER_IMAGE"
variables:
SAST_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/spotbugs:$SAST_ANALYZER_IMAGE_TAG"
rules:
- if: $SAST_DISABLED || $SAST_DISABLE_DIND == 'false'
when: never

View File

@ -10136,9 +10136,6 @@ msgstr ""
msgid "Expiration date"
msgstr ""
msgid "Expiration not enforced"
msgstr ""
msgid "Expired"
msgstr ""
@ -25980,6 +25977,9 @@ msgstr ""
msgid "Toggles :%{name}: emoji award."
msgstr ""
msgid "Token valid until revoked"
msgstr ""
msgid "Tomorrow"
msgstr ""

View File

@ -0,0 +1,145 @@
# frozen_string_literal: true
require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20200811130433_create_missing_vulnerabilities_issue_links.rb')
RSpec.describe CreateMissingVulnerabilitiesIssueLinks, :migration do
let(:namespace) { table(:namespaces).create!(name: 'user', path: 'user') }
let(:users) { table(:users) }
let(:user) { create_user! }
let(:project) { table(:projects).create!(id: 123, namespace_id: namespace.id) }
let(:scanners) { table(:vulnerability_scanners) }
let(:scanner) { scanners.create!(project_id: project.id, external_id: 'test 1', name: 'test scanner 1') }
let(:different_scanner) { scanners.create!(project_id: project.id, external_id: 'test 2', name: 'test scanner 2') }
let(:issues) { table(:issues) }
let(:issue1) { issues.create!(id: 123, project_id: project.id) }
let(:issue2) { issues.create!(id: 124, project_id: project.id) }
let(:vulnerabilities) { table(:vulnerabilities) }
let(:vulnerabilities_findings) { table(:vulnerability_occurrences) }
let(:vulnerability_feedback) { table(:vulnerability_feedback) }
let(:vulnerability_issue_links) { table(:vulnerability_issue_links) }
let(:vulnerability_identifiers) { table(:vulnerability_identifiers) }
let(:vulnerability_identifier) { vulnerability_identifiers.create!(project_id: project.id, external_type: 'test 1', external_id: 'test 1', fingerprint: 'test 1', name: 'test 1') }
let(:different_vulnerability_identifier) { vulnerability_identifiers.create!(project_id: project.id, external_type: 'test 2', external_id: 'test 2', fingerprint: 'test 2', name: 'test 2') }
let!(:vulnerability) do
create_vulnerability!(
project_id: project.id,
author_id: user.id
)
end
before do
create_finding!(
vulnerability_id: vulnerability.id,
project_id: project.id,
scanner_id: scanner.id,
primary_identifier_id: vulnerability_identifier.id
)
create_feedback!(
issue_id: issue1.id,
project_id: project.id,
author_id: user.id
)
# Create a finding with no vulnerability_id
# https://gitlab.com/gitlab-com/gl-infra/production/-/issues/2539
create_finding!(
vulnerability_id: nil,
project_id: project.id,
scanner_id: different_scanner.id,
primary_identifier_id: different_vulnerability_identifier.id,
location_fingerprint: 'somewhereinspace',
uuid: 'test2'
)
create_feedback!(
category: 2,
issue_id: issue2.id,
project_id: project.id,
author_id: user.id
)
end
context 'with no Vulnerabilities::IssueLinks present' do
it 'creates missing Vulnerabilities::IssueLinks' do
expect(vulnerability_issue_links.count).to eq(0)
migrate!
expect(vulnerability_issue_links.count).to eq(1)
end
end
context 'when an Vulnerabilities::IssueLink already exists' do
before do
vulnerability_issue_links.create!(vulnerability_id: vulnerability.id, issue_id: issue1.id)
end
it 'creates no duplicates' do
expect(vulnerability_issue_links.count).to eq(1)
migrate!
expect(vulnerability_issue_links.count).to eq(1)
end
end
private
def create_vulnerability!(project_id:, author_id:, title: 'test', severity: 7, confidence: 7, report_type: 0)
vulnerabilities.create!(
project_id: project_id,
author_id: author_id,
title: title,
severity: severity,
confidence: confidence,
report_type: report_type
)
end
# rubocop:disable Metrics/ParameterLists
def create_finding!(
vulnerability_id:, project_id:, scanner_id:, primary_identifier_id:,
name: "test", severity: 7, confidence: 7, report_type: 0,
project_fingerprint: '123qweasdzxc', location_fingerprint: 'test',
metadata_version: 'test', raw_metadata: 'test', uuid: 'test')
vulnerabilities_findings.create!(
vulnerability_id: vulnerability_id,
project_id: project_id,
name: name,
severity: severity,
confidence: confidence,
report_type: report_type,
project_fingerprint: project_fingerprint,
scanner_id: scanner.id,
primary_identifier_id: vulnerability_identifier.id,
location_fingerprint: location_fingerprint,
metadata_version: metadata_version,
raw_metadata: raw_metadata,
uuid: uuid
)
end
# rubocop:enable Metrics/ParameterLists
# project_fingerprint on Vulnerabilities::Finding is a bytea and we need to match this
def create_feedback!(issue_id:, project_id:, author_id:, feedback_type: 1, category: 0, project_fingerprint: '3132337177656173647a7863')
vulnerability_feedback.create!(
feedback_type: feedback_type,
issue_id: issue_id,
category: category,
project_fingerprint: project_fingerprint,
project_id: project_id,
author_id: author_id
)
end
def create_user!(name: "Example User", email: "user@example.com", user_type: nil, created_at: Time.now, confirmed_at: Time.now)
users.create!(
name: name,
email: email,
username: name,
projects_limit: 0,
user_type: user_type,
confirmed_at: confirmed_at
)
end
end