Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
cb605c69
Commit
cb605c69
authored
Aug 25, 2021
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab master
parents
bbbc98bf
718e32ca
Changes
19
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
82 additions
and
138 deletions
+82
-138
.gitlab/ci/rules.gitlab-ci.yml
.gitlab/ci/rules.gitlab-ci.yml
+12
-4
GITALY_SERVER_VERSION
GITALY_SERVER_VERSION
+1
-1
app/models/issue.rb
app/models/issue.rb
+1
-8
app/models/issue/metrics.rb
app/models/issue/metrics.rb
+0
-18
config/feature_flags/development/changes_batch_commits.yml
config/feature_flags/development/changes_batch_commits.yml
+0
-8
config/feature_flags/development/upsert_issue_metrics.yml
config/feature_flags/development/upsert_issue_metrics.yml
+0
-8
db/post_migrate/20210823193234_remove_allow_editing_commit_messages_from_project_settings.rb
...ve_allow_editing_commit_messages_from_project_settings.rb
+19
-0
db/schema_migrations/20210823193234
db/schema_migrations/20210823193234
+1
-0
db/structure.sql
db/structure.sql
+0
-1
ee/app/assets/javascripts/threat_monitoring/components/constants.js
...ets/javascripts/threat_monitoring/components/constants.js
+6
-5
ee/app/assets/javascripts/threat_monitoring/components/policies/policies_list.vue
...s/threat_monitoring/components/policies/policies_list.vue
+2
-1
ee/app/assets/javascripts/threat_monitoring/components/policy_editor/network_policy/lib/to_yaml.js
...ng/components/policy_editor/network_policy/lib/to_yaml.js
+1
-1
ee/app/assets/javascripts/threat_monitoring/components/policy_list.vue
.../javascripts/threat_monitoring/components/policy_list.vue
+2
-1
ee/app/assets/javascripts/threat_monitoring/utils.js
ee/app/assets/javascripts/threat_monitoring/utils.js
+3
-15
ee/spec/frontend/threat_monitoring/mocks/mock_data.js
ee/spec/frontend/threat_monitoring/mocks/mock_data.js
+4
-0
ee/spec/frontend/threat_monitoring/utils_spec.js
ee/spec/frontend/threat_monitoring/utils_spec.js
+8
-11
lib/gitlab/checks/changes_access.rb
lib/gitlab/checks/changes_access.rb
+1
-1
spec/lib/gitlab/checks/changes_access_spec.rb
spec/lib/gitlab/checks/changes_access_spec.rb
+20
-38
spec/models/issue/metrics_spec.rb
spec/models/issue/metrics_spec.rb
+1
-17
No files found.
.gitlab/ci/rules.gitlab-ci.yml
View file @
cb605c69
...
...
@@ -621,6 +621,8 @@
-
<<
:
*if-merge-request-title-run-all-rspec
-
<<
:
*if-merge-request
changes
:
*ci-patterns
-
<<
:
*if-merge-request
changes
:
*db-patterns
-
<<
:
*if-automated-merge-request
changes
:
*db-patterns
-
<<
:
*if-merge-request-not-approved
...
...
@@ -640,6 +642,7 @@
when
:
never
-
<<
:
*if-merge-request
changes
:
*db-patterns
when
:
never
.rails:rules:ee-and-foss-mr-with-migration:
rules
:
...
...
@@ -767,6 +770,8 @@
-
<<
:
*if-merge-request-title-run-all-rspec
-
<<
:
*if-merge-request
changes
:
*ci-patterns
-
<<
:
*if-merge-request
changes
:
*db-patterns
-
<<
:
*if-automated-merge-request
changes
:
*db-patterns
-
<<
:
*if-merge-request-not-approved
...
...
@@ -788,6 +793,7 @@
when
:
never
-
<<
:
*if-merge-request
changes
:
*db-patterns
when
:
never
.rails:rules:ee-only-unit:
rules
:
...
...
@@ -883,14 +889,14 @@
-
<<
:
*if-merge-request-title-run-all-rspec
-
<<
:
*if-merge-request
changes
:
*ci-patterns
-
<<
:
*if-automated-merge-request
changes
:
*db-patterns
-
<<
:
*if-merge-request-not-approved
when
:
never
-
<<
:
*if-security-merge-request
changes
:
*db-patterns
-
<<
:
*if-merge-request-title-as-if-foss
changes
:
*db-patterns
-
<<
:
*if-automated-merge-request
changes
:
*db-patterns
-
<<
:
*if-merge-request-not-approved
when
:
never
.rails:rules:as-if-foss-migration:minimal:
rules
:
...
...
@@ -905,8 +911,10 @@
when
:
never
-
<<
:
*if-security-merge-request
changes
:
*db-patterns
when
:
never
-
<<
:
*if-merge-request-title-as-if-foss
changes
:
*db-patterns
when
:
never
.rails:rules:as-if-foss-unit:
rules
:
...
...
GITALY_SERVER_VERSION
View file @
cb605c69
bdbed7a8a30246ee83d325615bb43213bf7a1d69
2ddefee1edfde10092a278a143c48fdcf86e380f
app/models/issue.rb
View file @
cb605c69
...
...
@@ -586,14 +586,7 @@ class Issue < ApplicationRecord
override
:ensure_metrics
def
ensure_metrics
return
Issue
::
Metrics
.
record!
(
self
)
if
Feature
.
enabled?
(
:upsert_issue_metrics
,
default_enabled: :yaml
)
if
!
association
(
:metrics
).
loaded?
||
metrics
.
blank?
metrics_record
=
Issue
::
Metrics
.
safe_find_or_create_by
(
issue:
self
)
self
.
metrics
=
metrics_record
end
metrics
.
record!
Issue
::
Metrics
.
record!
(
self
)
end
def
record_create_action
...
...
app/models/issue/metrics.rb
View file @
cb605c69
...
...
@@ -35,22 +35,4 @@ class Issue::Metrics < ApplicationRecord
issue
.
labels
.
joins
(
:lists
).
exists?
end
end
def
record!
if
issue
.
milestone_id
.
present?
&&
self
.
first_associated_with_milestone_at
.
blank?
self
.
first_associated_with_milestone_at
=
Time
.
current
end
if
issue_assigned_to_list_label?
&&
self
.
first_added_to_board_at
.
blank?
self
.
first_added_to_board_at
=
Time
.
current
end
self
.
save
end
private
def
issue_assigned_to_list_label?
issue
.
labels
.
joins
(
:lists
).
exists?
end
end
config/feature_flags/development/changes_batch_commits.yml
deleted
100644 → 0
View file @
bbbc98bf
---
name
:
changes_batch_commits
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/66731
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/336992
milestone
:
'
14.2'
type
:
development
group
:
group::gitaly
default_enabled
:
false
config/feature_flags/development/upsert_issue_metrics.yml
deleted
100644 → 0
View file @
bbbc98bf
---
name
:
upsert_issue_metrics
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/68509
rollout_issue_url
:
milestone
:
'
14.3'
type
:
development
group
:
group::project management
default_enabled
:
false
db/post_migrate/20210823193234_remove_allow_editing_commit_messages_from_project_settings.rb
0 → 100644
View file @
cb605c69
# frozen_string_literal: true
class
RemoveAllowEditingCommitMessagesFromProjectSettings
<
ActiveRecord
::
Migration
[
6.1
]
include
Gitlab
::
Database
::
MigrationHelpers
def
up
return
unless
column_exists?
(
:project_settings
,
:allow_editing_commit_messages
)
with_lock_retries
do
remove_column
:project_settings
,
:allow_editing_commit_messages
end
end
def
down
with_lock_retries
do
add_column
:project_settings
,
:allow_editing_commit_messages
,
:boolean
,
default:
false
,
null:
false
end
end
end
db/schema_migrations/20210823193234
0 → 100644
View file @
cb605c69
b85ef326056bb152d527e34b49caa3c40ee8685c3b14654992246c6adf082f8c
\ No newline at end of file
db/structure.sql
View file @
cb605c69
...
...
@@ -17342,7 +17342,6 @@ CREATE TABLE project_settings (
squash_option smallint DEFAULT 3,
has_confluence boolean DEFAULT false NOT NULL,
has_vulnerabilities boolean DEFAULT false NOT NULL,
allow_editing_commit_messages boolean DEFAULT false NOT NULL,
prevent_merge_without_jira_issue boolean DEFAULT false NOT NULL,
cve_id_request_enabled boolean DEFAULT true NOT NULL,
mr_default_target_self boolean DEFAULT false NOT NULL,
ee/app/assets/javascripts/threat_monitoring/components/constants.js
View file @
cb605c69
...
...
@@ -25,21 +25,22 @@ export { dateFormats as DATE_FORMATS } from '~/analytics/shared/constants';
export
const
POLICY_TYPE_COMPONENT_OPTIONS
=
{
container
:
{
component
:
'
network-policy-editor
'
,
kind
:
{
cilium
:
'
CiliumNetworkPolicy
'
,
network
:
'
NetworkPolicy
'
,
},
shouldShowEnvironmentPicker
:
true
,
text
:
s__
(
'
SecurityOrchestration|Network
'
),
typeName
:
'
NetworkPolicy
'
,
urlParameter
:
'
container_policy
'
,
value
:
'
container
'
,
yamlIndicator
:
{
cilium
:
'
CiliumNetworkPolicy
'
,
network
:
'
NetworkPolicy
'
,
},
},
scanExecution
:
{
component
:
'
scan-execution-policy-editor
'
,
text
:
s__
(
'
SecurityOrchestration|Scan Execution
'
),
typeName
:
'
ScanExecutionPolicy
'
,
urlParameter
:
'
scan_execution_policy
'
,
value
:
'
scanExecution
'
,
yamlIndicator
:
'
scanner_profile
'
,
},
};
...
...
ee/app/assets/javascripts/threat_monitoring/components/policies/policies_list.vue
View file @
cb605c69
...
...
@@ -167,7 +167,8 @@ export default {
return
''
;
},
policyType
()
{
return
this
.
selectedPolicy
?
getPolicyType
(
this
.
selectedPolicy
.
yaml
)
:
'
container
'
;
// eslint-disable-next-line no-underscore-dangle
return
this
.
selectedPolicy
?
getPolicyType
(
this
.
selectedPolicy
.
__typename
)
:
'
container
'
;
},
hasExistingPolicies
()
{
return
!
(
this
.
selectedPolicyType
===
POLICY_TYPE_OPTIONS
.
ALL
.
value
&&
!
this
.
policies
.
length
);
...
...
ee/app/assets/javascripts/threat_monitoring/components/policy_editor/network_policy/lib/to_yaml.js
View file @
cb605c69
...
...
@@ -48,7 +48,7 @@ export default function toYaml(policy) {
const
policySpec
=
{
apiVersion
:
'
cilium.io/v2
'
,
kind
:
POLICY_TYPE_COMPONENT_OPTIONS
.
container
.
yamlIndicator
.
cilium
,
kind
:
POLICY_TYPE_COMPONENT_OPTIONS
.
container
.
kind
.
cilium
,
};
if
(
description
?.
length
>
0
)
{
...
...
ee/app/assets/javascripts/threat_monitoring/components/policy_list.vue
View file @
cb605c69
...
...
@@ -168,7 +168,8 @@ export default {
:
''
;
},
policyType
()
{
return
this
.
selectedPolicy
?
getPolicyType
(
this
.
selectedPolicy
.
yaml
)
:
''
;
// eslint-disable-next-line no-underscore-dangle
return
this
.
selectedPolicy
?
getPolicyType
(
this
.
selectedPolicy
.
__typename
)
:
''
;
},
fields
()
{
const
environments
=
{
...
...
ee/app/assets/javascripts/threat_monitoring/utils.js
View file @
cb605c69
import
createGqClient
from
'
~/lib/graphql
'
;
import
{
POLICY_TYPE_COMPONENT_OPTIONS
}
from
'
./components/constants
'
;
/**
* Determines if the yaml passed in is of the type `container`
* @param {String} yaml the policy in yaml form
* @returns {Boolean}
*/
const
isContainerPolicyYaml
=
(
yaml
)
=>
{
const
containerYamlIndicator
=
Object
.
values
(
POLICY_TYPE_COMPONENT_OPTIONS
.
container
.
yamlIndicator
,
);
return
containerYamlIndicator
.
some
((
str
)
=>
yaml
?.
includes
(
str
));
};
/**
* Get the height of the wrapper page element
* This height can be used to determine where the highest element goes in a page
...
...
@@ -30,11 +18,11 @@ export const getContentWrapperHeight = (contentWrapperClass) => {
* @param {String} yaml policy's YAML manifest
* @returns {String|null} policy type if available
*/
export
const
getPolicyType
=
(
yaml
=
''
)
=>
{
if
(
isContainerPolicyYaml
(
yaml
)
)
{
export
const
getPolicyType
=
(
typeName
=
''
)
=>
{
if
(
typeName
===
POLICY_TYPE_COMPONENT_OPTIONS
.
container
.
typeName
)
{
return
POLICY_TYPE_COMPONENT_OPTIONS
.
container
.
value
;
}
if
(
yaml
?.
includes
(
POLICY_TYPE_COMPONENT_OPTIONS
.
scanExecution
.
yamlIndicator
)
)
{
if
(
typeName
===
POLICY_TYPE_COMPONENT_OPTIONS
.
scanExecution
.
typeName
)
{
return
POLICY_TYPE_COMPONENT_OPTIONS
.
scanExecution
.
value
;
}
return
null
;
...
...
ee/spec/frontend/threat_monitoring/mocks/mock_data.js
View file @
cb605c69
...
...
@@ -114,6 +114,7 @@ spec:
- cluster`
;
export
const
mockCiliumPolicy
=
{
__typename
:
'
NetworkPolicy
'
,
name
:
'
test-policy-03
'
,
updatedAt
:
new
Date
(
'
2021-06-07T00:00:00.000Z
'
),
yaml
:
mockCiliumManifest
,
...
...
@@ -121,6 +122,7 @@ export const mockCiliumPolicy = {
export
const
mockNetworkPoliciesResponse
=
[
{
__typename
:
'
NetworkPolicy
'
,
name
:
'
policy
'
,
kind
:
'
NetworkPolicy
'
,
yaml
:
mockNetworkManifest
,
...
...
@@ -132,6 +134,7 @@ export const mockNetworkPoliciesResponse = [
},
},
{
__typename
:
'
NetworkPolicy
'
,
name
:
'
test-policy-02
'
,
kind
:
'
CiliumNetworkPolicy
'
,
yaml
:
mockL3Manifest
,
...
...
@@ -145,6 +148,7 @@ export const mockNetworkPoliciesResponse = [
];
export
const
mockScanExecutionPolicy
=
{
__typename
:
'
ScanExecutionPolicy
'
,
name
:
'
Scheduled DAST scan
'
,
updatedAt
:
new
Date
(
'
2021-06-07T00:00:00.000Z
'
),
yaml
:
mockDastScanExecutionManifest
,
...
...
ee/spec/frontend/threat_monitoring/utils_spec.js
View file @
cb605c69
/* eslint-disable no-underscore-dangle */
import
{
POLICY_TYPE_COMPONENT_OPTIONS
}
from
'
ee/threat_monitoring/components/constants
'
;
import
{
getContentWrapperHeight
,
...
...
@@ -5,11 +6,7 @@ import {
removeUnnecessaryDashes
,
}
from
'
ee/threat_monitoring/utils
'
;
import
{
setHTMLFixture
}
from
'
helpers/fixtures
'
;
import
{
mockDastScanExecutionManifest
,
mockCiliumManifest
,
mockNetworkManifest
,
}
from
'
./mocks/mock_data
'
;
import
{
mockScanExecutionPolicy
,
mockNetworkPoliciesResponse
}
from
'
./mocks/mock_data
'
;
describe
(
'
Threat Monitoring Utils
'
,
()
=>
{
describe
(
'
getContentWrapperHeight
'
,
()
=>
{
...
...
@@ -36,12 +33,12 @@ describe('Threat Monitoring Utils', () => {
describe
(
'
getPolicyType
'
,
()
=>
{
it
.
each
`
input | output
${
''
}
|
${
null
}
${
'
random string
'
}
|
${
null
}
${
mockNetwork
Manifest
}
|
${
POLICY_TYPE_COMPONENT_OPTIONS
.
container
.
value
}
${
mock
CiliumManifest
}
|
${
POLICY_TYPE_COMPONENT_OPTIONS
.
container
.
value
}
${
mock
DastScanExecutionManifest
}
|
${
POLICY_TYPE_COMPONENT_OPTIONS
.
scanExecution
.
value
}
input
| output
${
''
}
|
${
null
}
${
'
UnknownPolicyType
'
}
|
${
null
}
${
mockNetwork
PoliciesResponse
[
0
].
__typename
}
|
${
POLICY_TYPE_COMPONENT_OPTIONS
.
container
.
value
}
${
mock
NetworkPoliciesResponse
[
1
].
__typename
}
|
${
POLICY_TYPE_COMPONENT_OPTIONS
.
container
.
value
}
${
mock
ScanExecutionPolicy
.
__typename
}
|
${
POLICY_TYPE_COMPONENT_OPTIONS
.
scanExecution
.
value
}
`
(
'
returns $output when used on $input
'
,
({
input
,
output
})
=>
{
expect
(
getPolicyType
(
input
)).
toBe
(
output
);
});
...
...
lib/gitlab/checks/changes_access.rb
View file @
cb605c69
...
...
@@ -81,7 +81,7 @@ module Gitlab
def
single_access_checks!
# Iterate over all changes to find if user allowed all of them to be applied
changes
.
each
do
|
change
|
commits
=
Gitlab
::
Lazy
.
new
{
commits_for
(
change
[
:newrev
])
}
if
Feature
.
enabled?
(
:changes_batch_commits
)
commits
=
Gitlab
::
Lazy
.
new
{
commits_for
(
change
[
:newrev
])
}
# If user does not have access to make at least one change, cancel all
# push by allowing the exception to bubble up
...
...
spec/lib/gitlab/checks/changes_access_spec.rb
View file @
cb605c69
...
...
@@ -8,53 +8,35 @@ RSpec.describe Gitlab::Checks::ChangesAccess do
subject
{
changes_access
}
describe
'#validate!'
do
shared_examples
'#validate!'
do
before
do
allow
(
project
).
to
receive
(
:lfs_enabled?
).
and_return
(
true
)
end
context
'without failed checks'
do
it
"doesn't raise an error"
do
expect
{
subject
.
validate!
}.
not_to
raise_error
end
it
'calls lfs checks'
do
expect_next_instance_of
(
Gitlab
::
Checks
::
LfsCheck
)
do
|
instance
|
expect
(
instance
).
to
receive
(
:validate!
)
end
before
do
allow
(
project
).
to
receive
(
:lfs_enabled?
).
and_return
(
true
)
end
subject
.
validate!
end
context
'without failed checks'
do
it
"doesn't raise an error"
do
expect
{
subject
.
validate!
}.
not_to
raise_error
end
context
'when time limit was reached'
do
it
'raises a TimeoutError'
do
logger
=
Gitlab
::
Checks
::
TimedLogger
.
new
(
start_time:
timeout
.
ago
,
timeout:
timeout
)
access
=
described_class
.
new
(
changes
,
project:
project
,
user_access:
user_access
,
protocol:
protocol
,
logger:
logger
)
expect
{
access
.
validate!
}.
to
raise_error
(
Gitlab
::
Checks
::
TimedLogger
::
TimeoutError
)
it
'calls lfs checks'
do
expect_next_instance_of
(
Gitlab
::
Checks
::
LfsCheck
)
do
|
instance
|
expect
(
instance
).
to
receive
(
:validate!
)
end
end
end
context
'with batched commits enabled'
do
before
do
stub_feature_flags
(
changes_batch_commits:
true
)
subject
.
validate!
end
it_behaves_like
'#validate!'
end
context
'with batched commits disabled'
do
before
do
stub_feature_flags
(
changes_batch_commits:
false
)
end
context
'when time limit was reached'
do
it
'raises a TimeoutError'
do
logger
=
Gitlab
::
Checks
::
TimedLogger
.
new
(
start_time:
timeout
.
ago
,
timeout:
timeout
)
access
=
described_class
.
new
(
changes
,
project:
project
,
user_access:
user_access
,
protocol:
protocol
,
logger:
logger
)
it_behaves_like
'#validate!'
expect
{
access
.
validate!
}.
to
raise_error
(
Gitlab
::
Checks
::
TimedLogger
::
TimeoutError
)
end
end
end
...
...
spec/models/issue/metrics_spec.rb
View file @
cb605c69
...
...
@@ -34,7 +34,7 @@ RSpec.describe Issue::Metrics do
end
end
shared_examples
"when recording the default set of issue metrics on issue save"
do
context
"when recording the default set of issue metrics on issue save"
do
context
"milestones"
do
it
"records the first time an issue is associated with a milestone"
do
time
=
Time
.
current
...
...
@@ -81,20 +81,4 @@ RSpec.describe Issue::Metrics do
end
end
end
context
'when upsert_issue_metrics is enabled'
do
before
do
stub_feature_flags
(
upsert_issue_metrics:
true
)
end
it_behaves_like
'when recording the default set of issue metrics on issue save'
end
context
'when upsert_issue_metrics is disabled'
do
before
do
stub_feature_flags
(
upsert_issue_metrics:
false
)
end
it_behaves_like
'when recording the default set of issue metrics on issue save'
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment