summaryrefslogtreecommitdiffstats
path: root/.gitlab-ci.yml
blob: 484f85bd44639f06cefb88a9a011276f7f226b8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
variables:
  # Locale settings do not affect the build, but might affect tests.
  LC_ALL: C

  CI_REGISTRY_IMAGE: registry.gitlab.isc.org/isc-projects/kea

  # Disabled shellcheck warnings:
  # SC1117: Backslash is literal in "\/". Prefer explicit escaping: "\\/".
  # SC2039: In POSIX sh, 'local' is undefined.
  # SC3043: In POSIX sh, 'local' is undefined.
  SHELLCHECK_OPTS: "--exclude=SC1117 --exclude=SC2039 --exclude=SC3043"

  # Setting this variable will affect all Security templates
  # (SAST, Dependency Scanning, ...)
  SECURE_ANALYZERS_PREFIX: "registry.gitlab.com/gitlab-org/security-products/analyzers"

  # Leave only bandit, flawfinder, semgrep.
  SAST_EXCLUDED_ANALYZERS: "eslint, spotbugs"

stages:
  - test

shellcheck:
  stage: test
  image: "${CI_REGISTRY_IMAGE}:latest"
  tags:
    - linux
    - amd64
  script:
    - SCRIPTS=
    - SCRIPTS+="src/bin/admin/admin-utils.sh "
    - SCRIPTS+="src/bin/admin/kea-admin.in "
    - SCRIPTS+="src/bin/admin/tests/admin_tests.sh.in "
    - SCRIPTS+="src/bin/admin/tests/cql_tests.sh.in "
    - SCRIPTS+="src/bin/admin/tests/memfile_tests.sh.in "
    - SCRIPTS+="src/bin/admin/tests/mysql_tests.sh.in "
    - SCRIPTS+="src/bin/admin/tests/pgsql_tests.sh.in "
    - SCRIPTS+="src/bin/agent/tests/ca_process_tests.sh.in "
    - SCRIPTS+="src/bin/d2/tests/d2_process_tests.sh.in "
    - SCRIPTS+="src/bin/dhcp4/tests/dhcp4_process_tests.sh.in "
    - SCRIPTS+="src/bin/dhcp6/tests/dhcp6_process_tests.sh.in "
    - SCRIPTS+="src/bin/keactrl/keactrl.conf.in "
    - SCRIPTS+="src/bin/keactrl/keactrl.in "
    - SCRIPTS+="src/bin/keactrl/tests/keactrl_tests.sh.in "
    - SCRIPTS+="src/bin/netconf/tests/shtests/netconf_tests.sh.in "
    - SCRIPTS+="src/bin/shell/tests/basic_auth_tests.sh.in "
    - SCRIPTS+="src/bin/shell/tests/shell_process_tests.sh.in "
    - SCRIPTS+="src/lib/asiolink/tests/process_spawn_app.sh.in "
    - SCRIPTS+="src/lib/log/tests/buffer_logger_test.sh.in "
    - SCRIPTS+="src/lib/log/tests/console_test.sh.in "
    - SCRIPTS+="src/lib/log/tests/destination_test.sh.in "
    - SCRIPTS+="src/lib/log/tests/init_logger_test.sh.in "
    - SCRIPTS+="src/lib/log/tests/local_file_test.sh.in "
    - SCRIPTS+="src/lib/log/tests/logger_lock_test.sh.in "
    - SCRIPTS+="src/lib/log/tests/severity_test.sh.in "
    - SCRIPTS+="src/lib/testutils/dhcp_test_lib.sh.in "
    - SCRIPTS+="src/lib/testutils/xml_reporting_test_lib.sh.in "
    - SCRIPTS+="src/hooks/dhcp/run_script/tests/run_script_test.sh.in "
    - SCRIPTS+="src/share/database/scripts/cql/upgrade_1.0_to_2.0.sh.in "
    - SCRIPTS+="src/share/database/scripts/cql/upgrade_2.0_to_3.0.sh.in "
    - SCRIPTS+="src/share/database/scripts/cql/upgrade_3.0_to_4.0.sh.in "
    - SCRIPTS+="src/share/database/scripts/cql/upgrade_4.0_to_5.0.sh.in "
    - SCRIPTS+="src/share/database/scripts/cql/wipe_data.sh.in "
    - SCRIPTS+="src/share/database/scripts/mysql/upgrade_1.0_to_2.0.sh.in "
    - SCRIPTS+="src/share/database/scripts/mysql/upgrade_2.0_to_3.0.sh.in "
    - SCRIPTS+="src/share/database/scripts/mysql/upgrade_3.0_to_4.0.sh.in "
    - SCRIPTS+="src/share/database/scripts/mysql/upgrade_4.0_to_4.1.sh.in "
    - SCRIPTS+="src/share/database/scripts/mysql/upgrade_4.1_to_5.0.sh.in "
    - SCRIPTS+="src/share/database/scripts/mysql/upgrade_5.0_to_5.1.sh.in "
    - SCRIPTS+="src/share/database/scripts/mysql/upgrade_5.1_to_5.2.sh.in "
    - SCRIPTS+="src/share/database/scripts/mysql/upgrade_5.2_to_6.0.sh.in "
    - SCRIPTS+="src/share/database/scripts/mysql/upgrade_6.0_to_7.0.sh.in "
    - SCRIPTS+="src/share/database/scripts/mysql/upgrade_7.0_to_8.0.sh.in "
    - SCRIPTS+="src/share/database/scripts/mysql/upgrade_8.0_to_8.1.sh.in "
    - SCRIPTS+="src/share/database/scripts/mysql/upgrade_8.1_to_8.2.sh.in "
    - SCRIPTS+="src/share/database/scripts/mysql/upgrade_8.2_to_9.0.sh.in "
    - SCRIPTS+="src/share/database/scripts/mysql/upgrade_9.0_to_9.1.sh.in "
    - SCRIPTS+="src/share/database/scripts/mysql/upgrade_9.1_to_9.2.sh.in "
    - SCRIPTS+="src/share/database/scripts/mysql/upgrade_9.2_to_9.3.sh.in "
    - SCRIPTS+="src/share/database/scripts/mysql/upgrade_9.3_to_9.4.sh.in "
    - SCRIPTS+="src/share/database/scripts/mysql/upgrade_9.4_to_9.5.sh.in "
    - SCRIPTS+="src/share/database/scripts/mysql/wipe_data.sh.in "
    - SCRIPTS+="src/share/database/scripts/pgsql/upgrade_1.0_to_2.0.sh.in "
    - SCRIPTS+="src/share/database/scripts/pgsql/upgrade_2.0_to_3.0.sh.in "
    - SCRIPTS+="src/share/database/scripts/pgsql/upgrade_3.0_to_3.1.sh.in "
    - SCRIPTS+="src/share/database/scripts/pgsql/upgrade_3.1_to_3.2.sh.in "
    - SCRIPTS+="src/share/database/scripts/pgsql/upgrade_3.2_to_3.3.sh.in "
    - SCRIPTS+="src/share/database/scripts/pgsql/upgrade_3.3_to_4.0.sh.in "
    - SCRIPTS+="src/share/database/scripts/pgsql/upgrade_4.0_to_5.0.sh.in "
    - SCRIPTS+="src/share/database/scripts/pgsql/upgrade_5.0_to_5.1.sh.in "
    - SCRIPTS+="src/share/database/scripts/pgsql/upgrade_5.1_to_6.0.sh.in "
    - SCRIPTS+="src/share/database/scripts/pgsql/upgrade_6.0_to_6.1.sh.in "
    - SCRIPTS+="src/share/database/scripts/pgsql/upgrade_6.1_to_6.2.sh.in "
    - SCRIPTS+="src/share/database/scripts/pgsql/wipe_data.sh.in "
    - SCRIPTS+="src/share/yang/modules/utils/check-hashes.sh "
    - SCRIPTS+="src/share/yang/modules/utils/check-revisions.sh "
    - SCRIPTS+="src/share/yang/modules/utils/gen-revisions.sh "
    - SCRIPTS+="src/share/yang/modules/utils/reinstall.sh.in "
    - SCRIPTS+="tools/add-config-h.sh "
    - SCRIPTS+="tools/bump-lib-versions.sh "
    - SCRIPTS+="tools/check-for-duplicate-includes.sh "
    - SCRIPTS+="tools/cql_config "
    - SCRIPTS+="tools/mk_cfgrpt.sh "
    - SCRIPTS+="tools/path_replacer.sh.in "
    - SCRIPTS+="tools/print-generated-files.sh "
    - SCRIPTS+="tools/shellcheck-all.sh "
    - SCRIPTS+="tools/tests_in_valgrind.sh "
    - shellcheck ${SCRIPTS} ${SHELLCHECK_OPTS}

danger:
  stage: test
  image: registry.gitlab.isc.org/isc-projects/stork/ci-danger
  tags:
    - linux
    - amd64
  before_script:
    - export CI_MERGE_REQUEST_ID=$(git ls-remote -q origin merge-requests\*\head | grep $CI_COMMIT_SHA | sed 's/.*refs\/merge-requests\/\([0-9]*\)\/head/\1/g')
    - export CI_PROJECT_PATH=$CI_PROJECT_ID #some version of gitlab has problems with searching by project path
    - export DANGER_GITLAB_HOST=gitlab.isc.org
    - export DANGER_GITLAB_API_BASE_URL=https://gitlab.isc.org/api/v4
  script:
    - sysctl -w net.ipv6.conf.all.disable_ipv6=1
    - sysctl -w net.ipv6.conf.default.disable_ipv6=1
    - gem install danger-commit_lint
    - danger --fail-on-errors=true --new-comment

duplicate-includes:
  stage: test
  image: "${CI_REGISTRY_IMAGE}:latest"
  tags:
    - linux
    - amd64
  script:
    - ./tools/check-for-duplicate-includes.sh

missing-config-h-include:
  stage: test
  image: "${CI_REGISTRY_IMAGE}:latest"
  tags:
    - linux
    - amd64
  script:
    - FILES=$(./tools/add-config-h.sh -n)
    - printf '%s\n' "${FILES}"
    - test -z "${FILES}"

missing-git-attribute:
  stage: test
  image: "${CI_REGISTRY_IMAGE}:latest"
  tags:
    - linux
    - amd64
  script:
    - git_diff=$(git diff)
    - if test -n "${git_diff}"; then printf '%s\n\ngit diff should be empty here under all circumstances. CI broken?\n' "${git_diff}"; exit 1; fi
    - ./tools/print-generated-files.sh -a
    - git_diff=$(git diff)
    - if test -n "${git_diff}"; then printf '%s\n\n.gitattributes are missing a generated file. Please run "./tools/print-generated-files.sh -a" and commit the resulting change to fix them.\n' "${git_diff}"; exit 1; fi

############################### SAST ################################
# Read more about this feature here: https://docs.gitlab.com/ee/user/application_security/sast/
#
# Configure SAST with CI/CD variables (https://docs.gitlab.com/ee/ci/variables/index.html).
# List of available variables: https://docs.gitlab.com/ee/user/application_security/sast/index.html#available-variables

include:
  - template: Security/SAST.gitlab-ci.yml

.sast-analyzer:
  extends: sast
  allow_failure: true
  script:
    - /analyzer run

flawfinder-sast:
  extends: .sast-analyzer
  image:
    name: "$SAST_ANALYZER_IMAGE"
  variables:
    SAST_ANALYZER_IMAGE_TAG: latest
    SAST_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/flawfinder:$SAST_ANALYZER_IMAGE_TAG"
  rules:
    - if: $SAST_DISABLED
      when: never
    - if: $SAST_EXCLUDED_ANALYZERS =~ /flawfinder/
      when: never
    - if: $CI_COMMIT_BRANCH
      exists:
        - '**/*.cc'
        - '**/*.h'