Skip to content
Snippets Groups Projects
Commit 50662b89 authored by Florie Guibert's avatar Florie Guibert :two:
Browse files

Merge branch '411984-add-unknown-license' into 'master'

Add Unknown license to Scan Result Policies

See merge request gitlab-org/gitlab!123565



Merged-by: default avatarFlorie Guibert <fguibert@gitlab.com>
Approved-by: default avatarMartin Čavoj <mcavoj@gitlab.com>
Approved-by: default avatarFlorie Guibert <fguibert@gitlab.com>
Reviewed-by: default avatarMartin Čavoj <mcavoj@gitlab.com>
Co-authored-by: default avatarMartin Čavoj <mcavoj@gitlab.com>
Co-authored-by: Alexander Turinske's avatarAlexander Turinske <aturinske@gitlab.com>
Co-authored-by: Alan (Maciej) Paruszewski's avatarAlan (Maciej) Paruszewski <mparuszewski@gitlab.com>
parents 056446e0 7078a138
No related branches found
No related tags found
1 merge request!123565Add Unknown license to Scan Result Policies
Pipeline #901894863 passed
......@@ -3,6 +3,11 @@ import { s__ } from '~/locale';
export const SEVERITY = 'severity';
export const STATUS = 'status';
export const UNKNOWN_LICENSE = {
value: 'unknown',
text: s__('ScanResultPolicy|Unknown'),
};
export const FILTERS = [
{
text: s__('ScanResultPolicy|New severity'),
......
......@@ -4,6 +4,7 @@ import { sprintf, s__ } from '~/locale';
import { parseBoolean } from '~/lib/utils/common_utils';
import BaseLayoutComponent from '../base_layout/base_layout_component.vue';
import { EXCEPT, MATCHING } from '../lib/rules';
import { UNKNOWN_LICENSE } from './constants';
export default {
i18n: {
......@@ -42,14 +43,17 @@ export default {
};
},
computed: {
allLicenses() {
return [...this.parsedSoftwareLicenses, UNKNOWN_LICENSE];
},
filteredLicenses() {
if (this.searchTerm) {
return this.parsedSoftwareLicenses.filter(({ value }) => {
return this.allLicenses.filter(({ value }) => {
return value.toLowerCase().includes(this.searchTerm.toLowerCase());
});
}
return this.parsedSoftwareLicenses;
return this.allLicenses;
},
licenseTypes: {
get() {
......@@ -75,8 +79,7 @@ export default {
const selectedValues = [this.licenseTypes].flat();
if (selectedValues.length === 1) {
toggleText = this.parsedSoftwareLicenses.find(({ value }) => value === selectedValues[0])
.text;
toggleText = this.allLicenses.find(({ value }) => value === selectedValues[0]).text;
}
if (selectedValues.length > 1) {
......
import BaseLayoutComponent from 'ee/security_orchestration/components/policy_editor/scan_result_policy/base_layout/base_layout_component.vue';
import LicenseFilter from 'ee/security_orchestration/components/policy_editor/scan_result_policy/scan_filters/license_filter.vue';
import { UNKNOWN_LICENSE } from 'ee/security_orchestration/components/policy_editor/scan_result_policy/scan_filters/constants';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import { licenseScanBuildRule } from 'ee/security_orchestration/components/policy_editor/scan_result_policy/lib/rules';
......@@ -17,6 +18,7 @@ describe('LicenseFilter', () => {
license_states: ['newly_detected', 'detected'],
});
const parsedSoftwareLicenses = [APACHE_LICENSE, MIT_LICENSE].map((l) => ({ text: l, value: l }));
const allLicenses = [...parsedSoftwareLicenses, UNKNOWN_LICENSE];
const createComponent = (props = DEFAULT_PROPS) => {
wrapper = shallowMountExtended(LicenseFilter, {
......@@ -57,9 +59,12 @@ describe('LicenseFilter', () => {
expect(wrapper.emitted('changed')).toStrictEqual([[{ license_types: MIT_LICENSE }]]);
});
it('displays all licenses', () => {
expect(findLicenseTypeListBox().props('items')).toStrictEqual(allLicenses);
});
it('filters the licenses when searching', async () => {
const listBox = findLicenseTypeListBox();
expect(listBox.props('items')).toStrictEqual(parsedSoftwareLicenses);
await listBox.vm.$emit('search', APACHE_LICENSE);
expect(listBox.props('items')).toStrictEqual([
{ value: APACHE_LICENSE, text: APACHE_LICENSE },
......@@ -96,7 +101,7 @@ describe('LicenseFilter', () => {
it('can select single all licence types', () => {
findLicenseTypeListBox().vm.$emit('select-all');
expect(wrapper.emitted('changed')).toEqual([
[expect.objectContaining({ license_types: parsedSoftwareLicenses })],
[expect.objectContaining({ license_types: allLicenses })],
]);
});
......
......@@ -40474,6 +40474,9 @@ msgstr ""
msgid "ScanResultPolicy|Status is:"
msgstr ""
 
msgid "ScanResultPolicy|Unknown"
msgstr ""
msgid "ScanResultPolicy|When %{scanType} %{scanners} runs against the %{branches} and find(s) %{vulnerabilitiesNumber} %{boldDescription} of the following criteria:"
msgstr ""
 
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment