diff options
20 files changed, 159 insertions, 39 deletions
diff --git a/app/assets/javascripts/ide/stores/actions/file.js b/app/assets/javascripts/ide/stores/actions/file.js index 59445afc7a4..0393f3859a9 100644 --- a/app/assets/javascripts/ide/stores/actions/file.js +++ b/app/assets/javascripts/ide/stores/actions/file.js @@ -5,7 +5,7 @@ import eventHub from '../../eventhub'; import service from '../../services'; import * as types from '../mutation_types'; import router from '../../ide_router'; -import { setPageTitle, replaceFileUrl } from '../utils'; +import { setPageTitle, replaceFileUrl, addFinalNewlineIfNeeded } from '../utils'; import { viewerTypes, stageKeys } from '../../constants'; export const closeFile = ({ commit, state, dispatch }, file) => { @@ -140,7 +140,10 @@ export const getRawFileData = ({ state, commit, dispatch, getters }, { path }) = export const changeFileContent = ({ commit, dispatch, state }, { path, content }) => { const file = state.entries[path]; - commit(types.UPDATE_FILE_CONTENT, { path, content }); + commit(types.UPDATE_FILE_CONTENT, { + path, + content: addFinalNewlineIfNeeded(content), + }); const indexOfChangedFile = state.changedFiles.findIndex(f => f.path === path); diff --git a/app/assets/javascripts/ide/stores/utils.js b/app/assets/javascripts/ide/stores/utils.js index a8d8ff31afe..3ccb3722e6f 100644 --- a/app/assets/javascripts/ide/stores/utils.js +++ b/app/assets/javascripts/ide/stores/utils.js @@ -269,3 +269,7 @@ export const pathsAreEqual = (a, b) => { return cleanA === cleanB; }; + +// if the contents of a file dont end with a newline, this function adds a newline +export const addFinalNewlineIfNeeded = content => + content.charAt(content.length - 1) !== '\n' ? `${content}\n` : content; diff --git a/app/assets/javascripts/main.js b/app/assets/javascripts/main.js index 007eecdd293..465c9a362ba 100644 --- a/app/assets/javascripts/main.js +++ b/app/assets/javascripts/main.js @@ -160,24 +160,6 @@ function deferredInitialisation() { }); loadAwardsHandler(); - - /** - * Toggle Canary Badge - * - * For GitLab.com only, when the user is using canary - * we render a Next badge and hide the option to switch - * to canay - */ - if (Cookies.get('gitlab_canary') && Cookies.get('gitlab_canary') === 'true') { - const canaryBadge = document.querySelector('.js-canary-badge'); - const canaryLink = document.querySelector('.js-canary-link'); - if (canaryBadge) { - canaryBadge.classList.remove('hidden'); - } - if (canaryLink) { - canaryLink.classList.add('hidden'); - } - } } document.addEventListener('DOMContentLoaded', () => { diff --git a/app/views/layouts/header/_current_user_dropdown.html.haml b/app/views/layouts/header/_current_user_dropdown.html.haml index efe74ddd902..484a5053a4b 100644 --- a/app/views/layouts/header/_current_user_dropdown.html.haml +++ b/app/views/layouts/header/_current_user_dropdown.html.haml @@ -35,8 +35,8 @@ %li.d-md-none = render 'shared/user_dropdown_contributing_link' = render_if_exists 'shared/user_dropdown_instance_review' - - if Gitlab.com? - %li.js-canary-link.d-md-none + - if Gitlab.com_but_not_canary? + %li.d-md-none = link_to _("Switch to GitLab Next"), "https://next.gitlab.com/" - if current_user_menu?(:sign_out) diff --git a/app/views/layouts/header/_default.html.haml b/app/views/layouts/header/_default.html.haml index d8697be7f7a..5719fb24b89 100644 --- a/app/views/layouts/header/_default.html.haml +++ b/app/views/layouts/header/_default.html.haml @@ -18,8 +18,8 @@ - if logo_text.present? %span.logo-text.d-none.d-lg-block.prepend-left-8 = logo_text - - if Gitlab.com? - = link_to 'https://next.gitlab.com', class: 'label-link js-canary-badge canary-badge bg-transparent hidden', target: :_blank do + - if Gitlab.com_and_canary? + = link_to 'https://next.gitlab.com', class: 'label-link canary-badge bg-transparent', target: :_blank do %span.color-label.has-tooltip.badge.badge-pill.green-badge = _('Next') diff --git a/app/views/layouts/header/_help_dropdown.html.haml b/app/views/layouts/header/_help_dropdown.html.haml index 71977b23481..93854c212df 100644 --- a/app/views/layouts/header/_help_dropdown.html.haml +++ b/app/views/layouts/header/_help_dropdown.html.haml @@ -12,6 +12,6 @@ %li = render 'shared/user_dropdown_contributing_link' = render_if_exists 'shared/user_dropdown_instance_review' - - if Gitlab.com? - %li.js-canary-link + - if Gitlab.com_but_not_canary? + %li = link_to _("Switch to GitLab Next"), "https://next.gitlab.com/" diff --git a/changelogs/unreleased/28801-fix-canary-inconsistency.yml b/changelogs/unreleased/28801-fix-canary-inconsistency.yml new file mode 100644 index 00000000000..fae9dd241fe --- /dev/null +++ b/changelogs/unreleased/28801-fix-canary-inconsistency.yml @@ -0,0 +1,5 @@ +--- +title: Fix canary badge and favicon inconsistency +merge_request: 19645 +author: +type: fixed diff --git a/changelogs/unreleased/33460-webide-line-endings.yml b/changelogs/unreleased/33460-webide-line-endings.yml new file mode 100644 index 00000000000..62fe15c051b --- /dev/null +++ b/changelogs/unreleased/33460-webide-line-endings.yml @@ -0,0 +1,5 @@ +--- +title: 'Resolve: Web IDE does not create POSIX Compliant Files' +merge_request: 19339 +author: +type: fixed diff --git a/changelogs/unreleased/consider-location-fingerprint-in-mr-widget.yml b/changelogs/unreleased/consider-location-fingerprint-in-mr-widget.yml new file mode 100644 index 00000000000..5d5edf25a3c --- /dev/null +++ b/changelogs/unreleased/consider-location-fingerprint-in-mr-widget.yml @@ -0,0 +1,5 @@ +--- +title: Use fingerprint when comparing security reports in MR widget +merge_request: 19654 +author: +type: fixed diff --git a/doc/user/application_security/dast/index.md b/doc/user/application_security/dast/index.md index 951c4b9dd73..d285b5ff585 100644 --- a/doc/user/application_security/dast/index.md +++ b/doc/user/application_security/dast/index.md @@ -339,3 +339,33 @@ questions that you know someone might ask. Each scenario can be a third-level heading, e.g. `### Getting error message X`. If you have none to add when creating a doc, leave this section in place but commented out to help encourage others to add to it in the future. --> + +## Troubleshooting + +### Running out of memory + +By default, ZAProxy, which DAST relies on, is allocated memory that sums to 25% +of the total memory on the host. +Since it keeps most of its information in memory during a scan, +it is possible for DAST to run out of memory while scanning large applications. +This results in the following error: + +``` +[zap.out] java.lang.OutOfMemoryError: Java heap space +``` + +Fortunately, it is straightforward to increase the amount of memory available +for DAST by overwriting the `script` key in the DAST template: + +```yaml +include: + template: DAST.gitlab-ci.yml + +dast: + script: + - export DAST_WEBSITE=${DAST_WEBSITE:-$(cat environment_url.txt)} + - /analyze -t $DAST_WEBSITE -z"-Xmx3072m" +``` + +Here, DAST is being allocated 3072 MB. +Change the number after `-Xmx` to the required memory amount. diff --git a/doc/user/application_security/license_compliance/index.md b/doc/user/application_security/license_compliance/index.md index c67e66dae5d..3cf8301adca 100644 --- a/doc/user/application_security/license_compliance/index.md +++ b/doc/user/application_security/license_compliance/index.md @@ -104,6 +104,7 @@ License Compliance can be configured using environment variables. | Environment variable | Required | Description | |-----------------------|----------|-------------| | `MAVEN_CLI_OPTS` | no | Additional arguments for the mvn executable. If not supplied, defaults to `-DskipTests`. | +| `LICENSE_FINDER_CLI_OPTS` | no | Additional arguments for the `license_finder` executable. For example, if your project has both Golang and Ruby code stored in different directories and you want to only scan the Ruby code, you can update your `.gitlab-ci-yml` template to specify which project directories to scan, like `LICENSE_FINDER_CLI_OPTS: '--debug --aggregate-paths=. ruby'`. | | `LM_JAVA_VERSION` | no | Version of Java. If set to `11`, Maven and Gradle use Java 11 instead of Java 8. | | `LM_PYTHON_VERSION` | no | Version of Python. If set to `3`, dependencies are installed using Python 3 instead of Python 2.7. | | `SETUP_CMD` | no | Custom setup for the dependency installation. (experimental) | diff --git a/lib/gitlab.rb b/lib/gitlab.rb index ad8e693ccbc..0e6db54eb46 100644 --- a/lib/gitlab.rb +++ b/lib/gitlab.rb @@ -47,6 +47,18 @@ module Gitlab Gitlab.config.gitlab.url == COM_URL || gl_subdomain? end + def self.canary? + Gitlab::Utils.to_boolean(ENV['CANARY']) + end + + def self.com_and_canary? + com? && canary? + end + + def self.com_but_not_canary? + com? && !canary? + end + def self.org? Gitlab.config.gitlab.url == 'https://dev.gitlab.org' end diff --git a/lib/gitlab/favicon.rb b/lib/gitlab/favicon.rb index b5d308e462c..ce1370bab0f 100644 --- a/lib/gitlab/favicon.rb +++ b/lib/gitlab/favicon.rb @@ -7,7 +7,7 @@ module Gitlab image_name = if appearance.favicon.exists? appearance.favicon_path - elsif Gitlab::Utils.to_boolean(ENV['CANARY']) + elsif Gitlab.canary? 'favicon-yellow.png' elsif Rails.env.development? development_favicon diff --git a/package.json b/package.json index fa070578ada..f72d650771f 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "@babel/plugin-syntax-import-meta": "^7.2.0", "@babel/preset-env": "^7.6.2", "@gitlab/svgs": "^1.80.0", - "@gitlab/ui": "7.3.0", + "@gitlab/ui": "7.5.0", "@gitlab/visual-review-tools": "1.0.3", "@sentry/browser": "^5.7.1", "apollo-cache-inmemory": "^1.5.1", diff --git a/spec/javascripts/ide/components/repo_editor_spec.js b/spec/javascripts/ide/components/repo_editor_spec.js index d1b43df74b9..21fb5449858 100644 --- a/spec/javascripts/ide/components/repo_editor_spec.js +++ b/spec/javascripts/ide/components/repo_editor_spec.js @@ -261,10 +261,10 @@ describe('RepoEditor', () => { }); it('updates state when model content changed', done => { - vm.model.setValue('testing 123'); + vm.model.setValue('testing 123\n'); setTimeout(() => { - expect(vm.file.content).toBe('testing 123'); + expect(vm.file.content).toBe('testing 123\n'); done(); }); diff --git a/spec/javascripts/ide/stores/actions/file_spec.js b/spec/javascripts/ide/stores/actions/file_spec.js index 021c3076094..472128ad834 100644 --- a/spec/javascripts/ide/stores/actions/file_spec.js +++ b/spec/javascripts/ide/stores/actions/file_spec.js @@ -455,6 +455,8 @@ describe('IDE store file actions', () => { beforeEach(() => { tmpFile = file('tmpFile'); + tmpFile.content = '\n'; + tmpFile.raw = '\n'; store.state.entries[tmpFile.path] = tmpFile; }); @@ -462,10 +464,24 @@ describe('IDE store file actions', () => { store .dispatch('changeFileContent', { path: tmpFile.path, + content: 'content\n', + }) + .then(() => { + expect(tmpFile.content).toBe('content\n'); + + done(); + }) + .catch(done.fail); + }); + + it('adds a newline to the end of the file if it doesnt already exist', done => { + store + .dispatch('changeFileContent', { + path: tmpFile.path, content: 'content', }) .then(() => { - expect(tmpFile.content).toBe('content'); + expect(tmpFile.content).toBe('content\n'); done(); }) @@ -510,12 +526,12 @@ describe('IDE store file actions', () => { store .dispatch('changeFileContent', { path: tmpFile.path, - content: 'content', + content: 'content\n', }) .then(() => store.dispatch('changeFileContent', { path: tmpFile.path, - content: '', + content: '\n', }), ) .then(() => { diff --git a/spec/javascripts/ide/stores/modules/commit/actions_spec.js b/spec/javascripts/ide/stores/modules/commit/actions_spec.js index 95d927065f0..d464f30b947 100644 --- a/spec/javascripts/ide/stores/modules/commit/actions_spec.js +++ b/spec/javascripts/ide/stores/modules/commit/actions_spec.js @@ -292,6 +292,8 @@ describe('IDE commit module actions', () => { type: 'blob', active: true, lastCommitSha: TEST_COMMIT_SHA, + content: '\n', + raw: '\n', }; Object.assign(store.state, { @@ -359,7 +361,7 @@ describe('IDE commit module actions', () => { { action: commitActionTypes.update, file_path: jasmine.anything(), - content: undefined, + content: '\n', encoding: jasmine.anything(), last_commit_id: undefined, previous_path: undefined, @@ -386,7 +388,7 @@ describe('IDE commit module actions', () => { { action: commitActionTypes.update, file_path: jasmine.anything(), - content: undefined, + content: '\n', encoding: jasmine.anything(), last_commit_id: TEST_COMMIT_SHA, previous_path: undefined, diff --git a/spec/javascripts/ide/stores/utils_spec.js b/spec/javascripts/ide/stores/utils_spec.js index a477d4fc200..1b4a158927c 100644 --- a/spec/javascripts/ide/stores/utils_spec.js +++ b/spec/javascripts/ide/stores/utils_spec.js @@ -597,4 +597,17 @@ describe('Multi-file store utils', () => { }); }); }); + + describe('addFinalNewlineIfNeeded', () => { + it('adds a newline if it doesnt already exist', () => { + [ + { input: 'some text', output: 'some text\n' }, + { input: 'some text\n', output: 'some text\n' }, + { input: 'some text\n\n', output: 'some text\n\n' }, + { input: 'some\n text', output: 'some\n text\n' }, + ].forEach(({ input, output }) => { + expect(utils.addFinalNewlineIfNeeded(input)).toEqual(output); + }); + }); + }); }); diff --git a/spec/lib/gitlab_spec.rb b/spec/lib/gitlab_spec.rb index 6bf837f1d3f..9362ff72fbc 100644 --- a/spec/lib/gitlab_spec.rb +++ b/spec/lib/gitlab_spec.rb @@ -96,6 +96,48 @@ describe Gitlab do end end + describe '.canary?' do + it 'is true when CANARY env var is set to true' do + stub_env('CANARY', '1') + + expect(described_class.canary?).to eq true + end + + it 'is false when CANARY env var is set to false' do + stub_env('CANARY', '0') + + expect(described_class.canary?).to eq false + end + end + + describe '.com_and_canary?' do + it 'is true when on .com and canary' do + allow(described_class).to receive_messages(com?: true, canary?: true) + + expect(described_class.com_and_canary?).to eq true + end + + it 'is false when on .com but not on canary' do + allow(described_class).to receive_messages(com?: true, canary?: false) + + expect(described_class.com_and_canary?).to eq false + end + end + + describe '.com_but_not_canary?' do + it 'is false when on .com and canary' do + allow(described_class).to receive_messages(com?: true, canary?: true) + + expect(described_class.com_but_not_canary?).to eq false + end + + it 'is true when on .com but not on canary' do + allow(described_class).to receive_messages(com?: true, canary?: false) + + expect(described_class.com_but_not_canary?).to eq true + end + end + describe '.dev_env_org_or_com?' do it 'is true when on .com' do allow(described_class).to receive_messages(com?: true, org?: false) diff --git a/yarn.lock b/yarn.lock index a5e727dae8d..73596e3be50 100644 --- a/yarn.lock +++ b/yarn.lock @@ -995,10 +995,10 @@ resolved "https://registry.yarnpkg.com/@gitlab/svgs/-/svgs-1.80.0.tgz#52b2d25f002cdfe9bd7c366a043c1849687ad64b" integrity sha512-hsyX3EZV/hk9bMTvvoxVcNC0EO6sy771BC2vXjqGtzjye4hTs0BTAzu3V0UPWuDompHtKXi/plVcJU+NxNLQ6Q== -"@gitlab/ui@7.3.0": - version "7.3.0" - resolved "https://registry.yarnpkg.com/@gitlab/ui/-/ui-7.3.0.tgz#9ed6d2144cb999c12675b309ecda3279c4b88bf6" - integrity sha512-QMn84x7DrjDOCKD1/Exh26wwkAvdAjlIWjafvISTHZ+PAWY6XxEAYyjllM5k0fQpNZP3sw7sBWWYvezDVdLnmw== +"@gitlab/ui@7.5.0": + version "7.5.0" + resolved "https://registry.yarnpkg.com/@gitlab/ui/-/ui-7.5.0.tgz#d25567157d20bb64741ab51b6b9f770ea49e634d" + integrity sha512-h7RxNMtQ1+KHK2uV+nb5d7UlqBVOtj9VGXqRXqVinc1b1x0onnvFFnYjgxf7XbXdsZq85ZyTlZa1SkduRig+Eg== dependencies: "@babel/standalone" "^7.0.0" "@gitlab/vue-toasted" "^1.2.1" |