@@ -27,6 +27,7 @@ stages:
2727 - build
2828 - test
2929 - Salsa-CI
30+ - sast
3031
3132default :
3233 # Base image for builds and tests unless otherwise defined
@@ -206,7 +207,7 @@ fedora-sanitizer:
206207 - builddir/_CPack_Packages/Linux/RPM/SPECS/
207208 parallel :
208209 matrix :
209- - SANITIZER : [-DWITH_ASAN=YES, -DWITH_TSAN=YES, -DWITH_UBSAN=YES, -DWITH_MSAN=YES ]
210+ - SANITIZER : [-DWITH_ASAN=YES, -DWITH_TSAN=YES, -DWITH_UBSAN=YES]
210211
211212centos8 :
212213 stage : build
@@ -298,6 +299,7 @@ centos7:
298299 main.mysqldump : Field separator argument is not what is expected; check the manual when executing 'SELECT INTO OUTFILE'
299300 main.flush_logs_not_windows : query 'flush logs' succeeded - should have failed with error ER_CANT_CREATE_FILE (1004)
300301 main.mysql_upgrade_noengine : upgrade output order does not match the expected
302+ main.func_math : MDEV-20966 - Wrong error code
301303 " > skiplist
302304 - ./mtr --suite=main --force --parallel=auto --xml-report=$CI_PROJECT_DIR/junit.xml --skip-test-list=skiplist $RESTART_POLICY
303305
@@ -370,22 +372,6 @@ mysql-test-run-ubsan:
370372 junit :
371373 - junit.xml
372374
373- mysql-test-run-msan :
374- stage : test
375- variables :
376- RESTART_POLICY : " --force-restart"
377- dependencies :
378- - " fedora-sanitizer: [-DWITH_MSAN=YES]"
379- needs :
380- - " fedora-sanitizer: [-DWITH_MSAN=YES]"
381- << : *mysql-test-run-def
382- allow_failure : true
383- artifacts :
384- when : always # Also show results when tests fail
385- reports :
386- junit :
387- - junit.xml
388-
389375rpmlint :
390376 stage : test
391377 dependencies :
@@ -440,52 +426,70 @@ fedora install:
440426 - installed-database.sql
441427 - upgraded-database.sql
442428
443- fedora upgrade :
444- stage : test
445- dependencies :
446- - fedora
447- needs :
448- - fedora
429+ cppcheck :
430+ stage : sast
431+ needs : []
432+ variables :
433+ GIT_STRATEGY : fetch
434+ GIT_SUBMODULE_STRATEGY : normal
449435 script :
450- - dnf install -y mariadb-server
451- # Fedora does not support running services in Docker (like Debian packages do) so start it manually
452- - /usr/libexec/mariadb-check-socket
453- - /usr/libexec/mariadb-prepare-db-dir
454- - sudo -u mysql /usr/libexec/mariadbd --basedir=/usr & sleep 10
455- # Dump database contents in installed state
456- - mariadb-dump --all-databases --all-tablespaces --triggers --routines --events --skip-extended-insert > old-installed-database.sql
457- - /usr/libexec/mariadb-check-upgrade
458- # Dump database contents in upgraded state
459- - mariadb-dump --all-databases --all-tablespaces --triggers --routines --events --skip-extended-insert > old-upgraded-database.sql
460- - mariadb --skip-column-names -e "SELECT @@version, @@version_comment" # Show version
461- # @TODO: Upgrade from Fedora 33 MariaDB 10.4 to MariaDB.org latest does not work
462- # so do this manual step to remove conflicts until packaging is fixed
463- - yum remove -y mariadb-server-utils mariadb-gssapi-server mariadb-cracklib-password-check mariadb-backup mariadb-connector-c-config
464- - rm -f rpm/*debuginfo* # Not relevant in this test
465- - yum install -y rpm/*.rpm
466- # nothing provides galera-4 on Fedora, so this step fails if built with wsrep
467- - mysql -e "SHUTDOWN;"
468- - /usr/bin/mariadb-install-db # This step should not do anything on upgrades, just exit
469- - sudo -u mysql /usr/sbin/mariadbd & sleep 10
470- # Dump database contents in installed state
471- - mariadb-dump --all-databases --all-tablespaces --triggers --routines --events --skip-extended-insert > new-installed-database.sql || true
472- # The step above fails on: mariadb-dump: Couldn't execute 'show events': Cannot proceed, because event scheduler is disabled (1577)
473- # @TODO: Since we did a manual start, we also need to run upgrade manually
474- - /usr/bin/mariadb-upgrade
475- # Dump database contents in upgraded state
476- - mariadb-dump --all-databases --all-tablespaces --triggers --routines --events --skip-extended-insert > new-upgraded-database.sql
477- - |
478- mariadb --skip-column-names -e "SELECT @@version, @@version_comment" | tee /tmp/version
479- grep $MARIADB_MAJOR_VERSION /tmp/version || echo "MariaDB didn't upgrade properly"
480- - mariadb --table -e "SELECT * FROM mysql.global_priv; SHOW CREATE USER root@localhost; SHOW CREATE USER 'mariadb.sys'@localhost"
481- - mariadb --table -e "SELECT * FROM mysql.plugin; SHOW PLUGINS"
436+ - yum install -y cppcheck diffutils
437+ # --template: use a single-line template
438+ # --force: check large directories without warning
439+ # -i<directory>: ignore this directory when scanning
440+ # -j: run multiple cppcheck threads
441+ # Use newline to escape colon in yaml
442+ - >
443+ cppcheck --template="{file}:{line}: {severity}: {message}" --force
444+ client dbug extra include libmariadb libmysqld libservices mysql-test mysys mysys_ssl pcre plugin
445+ strings tests unittest vio wsrep-lib sql sql-common storage
446+ -istorage/mroonga -istorage/tokudb -istorage/spider -istorage/rocksdb -iextra/ -ilibmariadb/ -istorage/columnstore
447+ --output-file=cppcheck.txt -j $(nproc)
448+ # Parallel jobs may output findings in an nondeterministic order. Sort to match ignorelist.
449+ - cat cppcheck.txt | sort > cppcheck_sorted.txt
450+ # Remove line numbers for diff
451+ - sed 's/:[^:]*:/:/' cppcheck_sorted.txt > cppcheck_sorted_no_line_numbers.txt
452+ # Only print new issues not found in ignore list
453+ - echo "Problems found in ignore list that were not discovered by cppcheck (may have been fixed)."
454+ - diff --changed-group-format='%>' --unchanged-group-format='' cppcheck_sorted_no_line_numbers.txt tests/code_quality/cppcheck_ignorelist.txt || true
455+ - echo "Problems found by cppcheck that were not in ignore list."
456+ - diff --changed-group-format='%<' --unchanged-group-format='' cppcheck_sorted_no_line_numbers.txt tests/code_quality/cppcheck_ignorelist.txt > lines_not_ignored.txt || true
457+ - cat lines_not_ignored.txt && test ! -s lines_not_ignored.txt
482458 artifacts :
459+ when : always
483460 paths :
484- - old-installed-database.sql
485- - old-upgraded-database.sql
486- - new-installed-database.sql
487- - new-upgraded-database.sql
461+ - cppcheck_sorted.txt
488462
463+ flawfinder :
464+ stage : sast
465+ needs : []
466+ variables :
467+ GIT_STRATEGY : fetch
468+ GIT_SUBMODULE_STRATEGY : normal
469+ script :
470+ - yum install -y python3 python3-pip jq diffutils git
471+ - pip install flawfinder
472+ - flawfinder --falsepositive --quiet --html . > flawfinder-all-vulnerabilities.html
473+ - cat flawfinder-all-vulnerabilities.html | grep "Hits ="
474+ - flawfinder --falsepositive --quiet --minlevel=5 --sarif . > flawfinder-output.json
475+ # FlawFinder's --sarif output will display all vulnerabilities despite having --minlevel=5 specified.
476+ # Therefore, we postprocess the results with jq and filter out findings where the vulnerability level is less than 5.
477+ # Also in the SARIF output format, the vulnerabilities are ranked as 0.2/0.4/0.6/0.8/1.0 which correspond to the --minlevel=1/2/3/4/5 of FlawFinder.
478+ # Additionally, we sort the results because individual findings are consistent across different runs, but their ordering may not be.
479+ # Vulnerabilities can also be ignored in-line (/* Flawfinder: ignore */), but this option was chosen as to not clutter the codebase.
480+ - jq 'del(.runs[] | .tool | .driver | .rules) | del(.runs[] | .results[] | select(.rank < 1)) | del(.runs[] | .results[] | .locations[] | .physicalLocation | .region | .startLine) | .runs[0].results|=sort_by(.fingerprints)' flawfinder-output.json > flawfinder-min-level5.json
481+ # Diff against known vulnerabilities, but ignore the line number.
482+ - echo "Problems found in ignore list that were not discovered by flawfinder (may have been fixed)."
483+ - diff --changed-group-format='%>' --unchanged-group-format='' flawfinder-min-level5.json tests/code_quality/flawfinder_ignorelist.json || true
484+ - echo "Problems found by flawfinder that were not in ignore list."
485+ - diff --changed-group-format='%<' --unchanged-group-format='' flawfinder-min-level5.json tests/code_quality/flawfinder_ignorelist.json > lines_not_ignored.txt || true
486+ - cat lines_not_ignored.txt && test ! -s lines_not_ignored.txt
487+ artifacts :
488+ when : always
489+ paths :
490+ - flawfinder-all-vulnerabilities.html
491+ - flawfinder-min-level5.json
492+
489493mini-benchmark :
490494 stage : test
491495 dependencies :
0 commit comments