├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── docker-compose.yml ├── env-example ├── gitlab-post-reconfigure.sh ├── installer.sh ├── juice-shop ├── build-pipeline │ ├── .gitlab-ci.yml │ └── .gitlab │ │ └── docker-build.gitlab-ci.yml ├── dependency-check │ ├── .gitlab-ci.yml │ └── .gitlab │ │ └── dependency-check.gitlab-ci.yml ├── dependency-track │ ├── .gitlab-ci.yml │ └── .gitlab │ │ ├── dependency-track.gitlab-ci.yml │ │ └── docker-build.gitlab-ci.yml ├── detect-secrets │ ├── .gitlab-ci.yml │ └── .gitlab │ │ └── detect-secrets.gitlab-ci.yml ├── full-testing │ ├── .gitlab-ci.yml │ └── .gitlab │ │ └── sonarqube.gitlab-ci.yml ├── hadolint │ ├── .gitlab-ci.yml │ └── .gitlab │ │ └── hadolint.gitlab-ci.yml ├── nikto │ ├── .gitlab-ci.yml │ └── .gitlab │ │ └── nikto.gitlab-ci.yml ├── njsscan │ ├── .gitlab-ci.yml │ └── .gitlab │ │ └── njsscan.gitlab-ci.yml ├── sonarqube │ ├── .gitlab-ci.yml │ └── .gitlab │ │ └── sonarqube.gitlab-ci.yml ├── trivy │ ├── .gitlab-ci.yml │ └── .gitlab │ │ └── trivy.gitlab-ci.yml └── zap │ ├── .gitlab-ci.yml │ ├── .gitlab │ └── zap.gitlab-ci.yml │ └── zap.yaml ├── register-runners.sh └── update_checker.sh /.gitignore: -------------------------------------------------------------------------------- 1 | # Let's make sure the sensitive variables aren't shared 2 | .env 3 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## [3.1.0](https://github.com/PeterMosmans/gitlab-demolab/compare/3.0.0...3.1.0) (2024-03-14) 4 | 5 | 6 | ### Features 7 | 8 | * use consistent messaging while starting up ([a4bbe3f](https://github.com/PeterMosmans/gitlab-demolab/commit/a4bbe3f0dbee15d87d0faa6503635e69e637d3ac)) 9 | 10 | 11 | ### Bug Fixes 12 | 13 | * ensure that checkout for detect-secrets is not ambiguous ([cc85679](https://github.com/PeterMosmans/gitlab-demolab/commit/cc8567998ccc0b034216280012fee324f2a79ebb)) 14 | * move Trivy pipeline script to correct directory ([cd45488](https://github.com/PeterMosmans/gitlab-demolab/commit/cd45488b26dc72ea1ed29f103e70e47c2063264b)) 15 | * use Dependency-Track during subsequent tests ([aac6e2d](https://github.com/PeterMosmans/gitlab-demolab/commit/aac6e2da3dc911db8aa553c0a86b451c1e5dd8b1)) 16 | 17 | ## [3.0.0](https://github.com/PeterMosmans/gitlab-demolab/compare/2.1.0...3.0.0) (2024-03-10) 18 | 19 | 20 | ### Features 21 | 22 | * add demonstration pipeline scripts ([e2b8757](https://github.com/PeterMosmans/gitlab-demolab/commit/e2b8757625491123b3d5144b06ae5dfc9889e88a)) 23 | * add helper script to check whether images are up-to-date ([99e38d6](https://github.com/PeterMosmans/gitlab-demolab/commit/99e38d649c2cbd13fa38ef884d9772fbfbfd85d9)) 24 | * add warning when curl is not installed ([0e0ab70](https://github.com/PeterMosmans/gitlab-demolab/commit/0e0ab708f1ead9c792dc348018d1a3944c5d2e04)) 25 | * check version of gofwd/tools-image ([8f3812e](https://github.com/PeterMosmans/gitlab-demolab/commit/8f3812e34efe5640f18a3e6c08d3697e70f66e4c)) 26 | * improve and colorize installer script ([6bb4c6c](https://github.com/PeterMosmans/gitlab-demolab/commit/6bb4c6c5143fc0a2dcbfe54e02d1815244ac2938)) 27 | * improve initial configuration of SonarQube and Dependency-Track ([16d962d](https://github.com/PeterMosmans/gitlab-demolab/commit/16d962d0dc7ddbcd1c95c4476a53182929a6aa8e)) 28 | * update default version of tools ([97db81a](https://github.com/PeterMosmans/gitlab-demolab/commit/97db81a97f9116835cc69bef8e19efa661ed24eb)) 29 | * update defaults ([8953898](https://github.com/PeterMosmans/gitlab-demolab/commit/895389870dd526910ee11dcdb7ddfd19906cc9ed)) 30 | * use correct image for Docker in Docker ([bd69cd5](https://github.com/PeterMosmans/gitlab-demolab/commit/bd69cd5e8af7517f4293350d25ed02d24dba9e87)) 31 | * use faster Docker-in-docker driver by default ([eefd288](https://github.com/PeterMosmans/gitlab-demolab/commit/eefd288b32688a95d649f636e6163702b8be1590)) 32 | 33 | 34 | ### Bug Fixes 35 | 36 | * correct spelling error ([3beb41c](https://github.com/PeterMosmans/gitlab-demolab/commit/3beb41cb318165dba2baefbefb479ff95f786bd2)) 37 | 38 | ## [2.1.0](https://github.com/PeterMosmans/gitlab-demolab/compare/2.0.0...2.1.0) (2024-02-02) 39 | 40 | 41 | ### Features 42 | 43 | * add Dependency-Track Docker images ([aab412a](https://github.com/PeterMosmans/gitlab-demolab/commit/aab412a898bf3d4ccc575a3b2305162075f64496)) 44 | * add Dependency-Track variables ([e6384dc](https://github.com/PeterMosmans/gitlab-demolab/commit/e6384dcca37e56bd2f827122d338b26644987b56)) 45 | * parameterize extra shared Runner volume ([39596b5](https://github.com/PeterMosmans/gitlab-demolab/commit/39596b52e06baf1499be7735b718cc597c2f98e6)) 46 | * split out startup of services in installation file ([887676e](https://github.com/PeterMosmans/gitlab-demolab/commit/887676e072149e3d26ba52258e4b9e6aea1da45d)) 47 | * support shared Runner caches ([5c78706](https://github.com/PeterMosmans/gitlab-demolab/commit/5c78706f05c1d7decd1730f3c6b71a5862e6ad60)) 48 | * update GitLab version ([f2430df](https://github.com/PeterMosmans/gitlab-demolab/commit/f2430dfa9d0a1e233362e526012966072c0ebc59)) 49 | * update versions and add SonarQube plugins ([b8e0524](https://github.com/PeterMosmans/gitlab-demolab/commit/b8e0524a9f325f808f2402f065ac716afdce93aa)) 50 | * use named cache volume for runners ([4d3a351](https://github.com/PeterMosmans/gitlab-demolab/commit/4d3a351ff371a31e0686507210b27cc878aaa19a)) 51 | * use two runners with shared cache instead of three ([41b335e](https://github.com/PeterMosmans/gitlab-demolab/commit/41b335e3ab59ae481f6a7b0745afa84f90720837)) 52 | 53 | 54 | ### Bug Fixes 55 | 56 | * ensure that gitlab service name is being used for registration ([ecedc2e](https://github.com/PeterMosmans/gitlab-demolab/commit/ecedc2ed893d678962542ce5971275b8bb3edb7f)) 57 | * only configure SonarQube during the first run ([8b26e4a](https://github.com/PeterMosmans/gitlab-demolab/commit/8b26e4a9308647114c72abc1bc1a01f8862adcc3)) 58 | 59 | ## [2.0.0](https://github.com/PeterMosmans/gitlab-demolab/compare/1.6.0...2.0.0) (2024-01-17) 60 | 61 | 62 | ### ⚠ BREAKING CHANGES 63 | 64 | * check whether hostname can be resolved 65 | 66 | ### Features 67 | 68 | * automatically use supplied env-example file ([9163f41](https://github.com/PeterMosmans/gitlab-demolab/commit/9163f41b5698d15dcdb13f57f4ead3acacaff8ae)) 69 | * be more verbose when resolving hosts ([e99e22f](https://github.com/PeterMosmans/gitlab-demolab/commit/e99e22fe73e807a01281f45e9a221cca2fc4999a)) 70 | * check whether hostname can be resolved ([408a737](https://github.com/PeterMosmans/gitlab-demolab/commit/408a737000196cd653204d4ea8342fead1a5fc72)) 71 | * update gitlab version tag ([915d8d4](https://github.com/PeterMosmans/gitlab-demolab/commit/915d8d4caf5fd99c30ca48c8725079559f59e56a)) 72 | * update versions ([fe3b5be](https://github.com/PeterMosmans/gitlab-demolab/commit/fe3b5be03f2d3c213e011b238d1ef4a5abf5cb72)) 73 | * update versions and use localhost by default ([bd18a70](https://github.com/PeterMosmans/gitlab-demolab/commit/bd18a708171360920587c8df8b04877a9d5d95b4)) 74 | 75 | 76 | ### Bug Fixes 77 | 78 | * pass correct variables to gitlab runner ([c99b753](https://github.com/PeterMosmans/gitlab-demolab/commit/c99b75398c9f9ded64af956f6a153d342a3cc483)) 79 | 80 | ## [1.6.0](https://git.go-forward.net/PeterMosmans/gitlab-demolab/-/compare/1.5.0...1.6.0) (2023-10-25) 81 | 82 | 83 | ### Features 84 | 85 | * add script to register runners using a runner token ([6ee389a](https://git.go-forward.net/PeterMosmans/gitlab-demolab/-/commit/6ee389a1cc051c845f832bc49640be699081c849)) 86 | * remove auto registration token and scripts ([c008191](https://git.go-forward.net/PeterMosmans/gitlab-demolab/-/commit/c00819149c3307e8399214e311d3900b005f16da)) 87 | * rename runners and configuration volumes ([aceba3c](https://git.go-forward.net/PeterMosmans/gitlab-demolab/-/commit/aceba3cd2ad487f43f721ebdb74e0cfe493ad3c2)) 88 | * update versions of Docker images ([aaff903](https://git.go-forward.net/PeterMosmans/gitlab-demolab/-/commit/aaff9035429fe091363f1314d86e6e0184dc1772)) 89 | 90 | ## [1.5.0](https://git.go-forward.net/PeterMosmans/gitlab-demolab/-/compare/1.4.1...1.5.0) (2023-08-03) 91 | 92 | 93 | ### Features 94 | 95 | * bind separate volume by default ([3dbe42e](https://git.go-forward.net/PeterMosmans/gitlab-demolab/-/commit/3dbe42ecf69f42b0d377ded8e66676ba4372ffc9)) 96 | * display password when installlation finishes ([c5d98e4](https://git.go-forward.net/PeterMosmans/gitlab-demolab/-/commit/c5d98e4e49a073ca26970b1fe342c0a63c8e131f)) 97 | * make network name variable ([5e364a4](https://git.go-forward.net/PeterMosmans/gitlab-demolab/-/commit/5e364a4375e1ed519ac8ffb1dc5de10cb08237cc)) 98 | * only bind to localhost by default ([a29e95f](https://git.go-forward.net/PeterMosmans/gitlab-demolab/-/commit/a29e95fe69cb7c122ed398b2830bc9783d202e29)) 99 | 100 | ## [1.4.1](https://github.com/PeterMosmans/gitlab-demolab/compare/1.4.0...1.4.1) (2023-07-25) 101 | 102 | ## [1.4.0](https://github.com/PeterMosmans/gitlab-demolab/compare/1.3.0...1.4.0) (2023-05-31) 103 | 104 | ### Features 105 | 106 | * add installer script to start up demo lab ([3e3a636](https://github.com/PeterMosmans/gitlab-demolab/commit/3e3a636243d90bb29a276735fa169521906e94a4)) 107 | * update default variables with new versions ([6980dd0](https://github.com/PeterMosmans/gitlab-demolab/commit/6980dd054469578b87dabcca07b4a0aa7d104feb)) 108 | 109 | ## [1.3.0](https://git.go-forward.net/PeterMosmans/gitlab-demolab/-/compare/1.2.0...1.3.0) (2022-11-17) 110 | 111 | ### Features 112 | 113 | - parameterize SonarQube image 114 | ([46ec3dd](https://git.go-forward.net/PeterMosmans/gitlab-demolab/-/commit/46ec3dd415f9840a965174598b644994db25ec7d)) 115 | 116 | ## [1.2.0](https://git.go-forward.net/PeterMosmans/gitlab-demolab/-/compare/1.1.0...1.2.0) (2022-07-14) 117 | 118 | ### Features 119 | 120 | - add SonarQube as well as multiple runners 121 | ([0d6cbd3](https://git.go-forward.net/PeterMosmans/gitlab-demolab/-/commit/0d6cbd3ca6d77f4f8e5a7f661f82cf66250fb74e)) 122 | - always use latest version of gitlab runner 123 | ([567b7f1](https://git.go-forward.net/PeterMosmans/gitlab-demolab/-/commit/567b7f1398d6682f92827a7059fac7fb333438d4)) 124 | - ensure that register script can be used on any runner 125 | ([55ea69f](https://git.go-forward.net/PeterMosmans/gitlab-demolab/-/commit/55ea69fd2039cb3d08f7e7f6c3ca1de196becaa3)) 126 | - ensure that uploaded artifacts can be any size 127 | ([2b3dd7a](https://git.go-forward.net/PeterMosmans/gitlab-demolab/-/commit/2b3dd7ada12d8c5f55da32aaf2522418021c622b)) 128 | - update versions 129 | ([7a0473f](https://git.go-forward.net/PeterMosmans/gitlab-demolab/-/commit/7a0473faf6bcca966925f5f452cb6e62309a9c39)) 130 | 131 | ## [1.1.0](https://github.com/PeterMosmans/gitlab-demolab/compare/1.0.0...1.1.0) (2022-04-12) 132 | 133 | ### Features 134 | 135 | - ensure that GitLab version is parameterized 136 | ([7ed3785](https://github.com/PeterMosmans/gitlab-demolab/commit/7ed3785a5d97b57f3625cae1cd8c7e3bebddb0b7)) 137 | 138 | ## 1.0.0 (2022-02-11) 139 | 140 | ### Features 141 | 142 | - initial version 143 | ([28fc0ac](https://github.com/PeterMosmans/gitlab-demolab/commit/28fc0acadf3d0766b8b822e3ebf986532a29c386)) 144 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GitLab Demolab 2 | 3 | This repository contains all files to automatically configure and set up a local 4 | demo environment, consisting of a CI/CD GitLab Community Edition server and 5 | multiple (Docker-in-Docker) GitLab runners. Optionally, SonarQube Community 6 | Edition and Dependency-Track can be configured and set up as well. 7 | 8 | ## Prerequisites 9 | 10 | Have `curl`, `docker`, and `docker-compose` installed. 11 | 12 | ## Usage 13 | 14 | ```console 15 | ./installer.sh 16 | ``` 17 | 18 | This will fire up an instance of GitLab and two GitLab runners, capable of 19 | performing Docker-in-Docker commands. 20 | 21 | All variables are stored in an `.env` file: The `.env` file itself not supplied 22 | in this repository, but an example is. If you don't create an `.env` file before 23 | using the installer, it will automatically copy and use the `env-example` file 24 | for you. 25 | 26 | Then, you\'ll need to register the (group of) runners with a valid runner token, 27 | which needs to be created manually: In GitLab, go to the Admin Area / Dashboard, 28 | click on Instant Runners, and click on New instance runner 29 | (`/admin/runners/new`). Select \"Run untagged jobs\" and click on Create runner. 30 | This will generate a new runner token. Copy the token. 31 | 32 | Lastly, execute the `register-runners.sh` script with that token as parameter. 33 | This script will register all runners that are up and running. 34 | 35 | ## Starting and configuring SonarQube 36 | 37 | ```console 38 | ./installer.sh sonarqube 39 | ``` 40 | 41 | ## Starting and configuring Dependency-Track 42 | 43 | ```console 44 | ./installer.sh dependency-track 45 | ``` 46 | 47 | ## Stopping / pausing the demolab 48 | 49 | ```console 50 | ./installer.sh stop 51 | ``` 52 | 53 | ## Removing the demolab 54 | 55 | ```console 56 | docker-compose down 57 | ``` 58 | 59 | By default all data, configuration and logs will be stored in persistent Docker 60 | volumes. They will remain, even if you stop or remove the Docker containers. To 61 | clean everything up, remove the containers including named volumes. 62 | 63 | ```console 64 | docker-compose down --remove-orphans --volumes 65 | ``` 66 | 67 | Please note that this is a lab setup - and not meant to be used in production in 68 | any way. All services only bind / listen to `127.0.0.1` by default (this can be 69 | changed in the file `docker-compose`. 70 | 71 | Furthermore all runners share one named Docker volume as cache under 72 | `/srv/cache`. This named volume will be initialized by default, and has lax 73 | permissions (to ensure all tools can work with it). 74 | 75 | ## Juice Shop demonstration scripts 76 | 77 | Furthermore, the repository contains a number of pipeline example scripts, to 78 | help you add several automated security testing tools to a GitLab pipeline. The 79 | pipeline definition files can be found in the folder [juice-shop](juice-shop/): 80 | 81 | - [Basic build pipeline](juice-shop/build-pipeline/) 82 | - [Detecting secrets in a code base with detect-secrets](juice-shop/detect-secrets/) 83 | - [Dockerfile linting with Hadolint](juice-shop/hadolint/) 84 | - [SAST with Njsscan](juice-shop/njsscan/) 85 | - [SAST with SonarQube](juice-shop/sonarqube/) 86 | - [Software composition analysis with Dependency-Check](juice-shop/dependency-check/) 87 | - [Component analysis with Dependency-Track](juice-shop/dependency-track/) 88 | - [Container vulnerability scanning with Trivy](juice-shop/trivy/) 89 | - [DAST with ZAP](juice-shop/zap/) 90 | - [DAST with Nikto](juice-shop/nikto/) 91 | - [Full automated security testing](juice-shop/full-testing/) 92 | 93 | ## Variables 94 | 95 | The `DEMO_NAME` allows you to run multiple instances of this demo on the same 96 | machine, as it will generate its own \"Docker namespace\". 97 | 98 | `DIND_VERSION` defines the Docker-in-Docker image tag being used. 99 | 100 | `DTRACK_API_PORT` defines the port number of the Dependency-Track API interface. 101 | 102 | `DTRACK_API_VERSION` defines the Dependency-Track API image tag. 103 | 104 | `DTRACK_FRONTEND_PORT` defines the port number on which the web interface of 105 | Dependency-Track will be accessible. 106 | 107 | `DTRACK_FRONTEND_VERSION` defines the Dependency-Track frontend image tag. 108 | 109 | `GITLAB_HOSTNAME` defines the hostname that will be used to access GitLab. 110 | Please note that this name needs to be resolved, see the remarks at the bottom 111 | of this page. 112 | 113 | `GITLAB_PASSWORD` defines the initial password for user `root`. 114 | 115 | `GITLAB_PORT` defines the port number on which the web interface of GitLab will 116 | be accessible. 117 | 118 | `GITLAB_SSH` defines the SSH port number for GitLab. 119 | 120 | `GITLAB_VERSION` defines the GitLab image tag being used. Please note that the 121 | runners always use the latest version. 122 | 123 | `SONARQUBE_HOSTNAME` defines the hostname that will be used to access SonarQube. 124 | Please note that this name needs to be resolved, see the remarks at the bottom 125 | of this page. 126 | 127 | `SONARQUBE_PASSWORD` defines the initial password for user `admin`. 128 | 129 | `SONARQUBE_PLUGINS` defines a space-delimited list of SonarQube plugins that 130 | will be installed at first startup. 131 | 132 | `SONARQUBE_PORT` defines the port number on which the web interface of SonarQube 133 | will be accessible. 134 | 135 | `SONARQUBE_VERSION` allows you to specify which SonarQube image you would like 136 | to use. 137 | 138 | **Important!** 139 | 140 | The GITLAB_PASSWORD needs to be complex, otherwise installation will fail, see 141 | . 142 | 143 | If you want to access the web interfaces using \"pretty host names\" that are 144 | defined using `GITLAB_HOSTNAME` and `SONARQUBE_HOSTNAME` (instead of 145 | `localhost`), then make sure that they can be resolved by your browser. This can 146 | be done for instance by adding them to your local `hosts` file. 147 | 148 | # Copyright / License 149 | 150 | Great that you're using this code, hopefully you find it useful! All that I'm 151 | asking is that you properly attribute the author (Peter Mosmans), and respect 152 | the [GPLv3 license](LICENSE). 153 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Copyright (C) 2022-2024 Peter Mosmans [Go Forward] 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | # 5 | # Basic docker-compose file to start a GitLab demo network 6 | # Part of https://github.com/PeterMosmans/gitlab-demolab 7 | 8 | version: "3.5" 9 | 10 | # All services need to be part of the same network for communication 11 | networks: 12 | default: 13 | name: ${DEMO_NAME}-network 14 | 15 | # Volumes survive reboots and restarts 16 | volumes: 17 | dependency-track: 18 | name: ${DEMO_NAME}-dependency-track 19 | gitlab_config: 20 | name: ${DEMO_NAME}-gitlab_config 21 | gitlab_data: 22 | name: ${DEMO_NAME}-gitlab_data 23 | gitlab_logs: 24 | name: ${DEMO_NAME}-gitlab_logs 25 | gitlab_runner_config_1: 26 | name: ${DEMO_NAME}-gitlab_runner_config_1 27 | gitlab_runner_config_2: 28 | name: ${DEMO_NAME}-gitlab_runner_config_2 29 | runner_cache: 30 | name: ${DEMO_NAME}-runner_cache 31 | labels: 32 | net.go-forward.description: "Shared cache amongst GitLab runners" 33 | sonarqube_config: 34 | name: ${DEMO_NAME}-sonarqube_config 35 | sonarqube_data: 36 | name: ${DEMO_NAME}-sonarqube_data 37 | sonarqube_extensions: 38 | name: ${DEMO_NAME}-sonarqube_extensions 39 | sonarqube_logs: 40 | name: ${DEMO_NAME}-sonarqube_logs 41 | sonarqube_temp: 42 | name: ${DEMO_NAME}-sonarqube_temp 43 | driver_opts: 44 | type: tmpfs 45 | device: tmpfs 46 | 47 | services: 48 | # The GitLab instance 49 | gitlab: 50 | container_name: ${DEMO_NAME}-gitlab 51 | environment: 52 | # These settings will be evaluated on load - see 53 | # https://docs.gitlab.com/omnibus/docker/#pre-configure-docker-container 54 | GITLAB_OMNIBUS_CONFIG: | 55 | external_url 'http://${GITLAB_HOSTNAME}:${GITLAB_PORT}/' 56 | gitlab_rails['initial_root_password'] = '${GITLAB_PASSWORD}' 57 | gitlab_rails['rack_attack_git_basic_auth'] = { 58 | 'enabled' => true, 59 | 'ip_whitelist' => ['127.0.0.1'], 60 | 'maxretry' => 10, 61 | 'findtime' => 60, 62 | 'bantime' => 3600 63 | } 64 | gitlab_rails['time_zone'] = 'Europe/Amsterdam' 65 | gitlab_rails['usage_ping_enabled'] = false 66 | letsencrypt['enable'] = false 67 | nginx['listen_https'] = false 68 | nginx['client_max_body_size'] = '0' 69 | puma['port'] = 3456 70 | prometheus_monitoring['enable'] = false 71 | GITLAB_POST_RECONFIGURE_SCRIPT: /etc/gitlab/post-reconfigure.sh 72 | hostname: gitlab 73 | image: gitlab/gitlab-ce:${GITLAB_VERSION} 74 | ports: 75 | # GitLab reads the nginx port number from external_url 76 | - "127.0.0.1:${GITLAB_PORT}:${GITLAB_PORT}" 77 | - "127.0.0.1:${GITLAB_SSH}:22" 78 | restart: unless-stopped 79 | shm_size: "256m" 80 | stop_grace_period: 10m 81 | volumes: 82 | - gitlab_config:/etc/gitlab 83 | - gitlab_data:/var/opt/gitlab 84 | - gitlab_logs:/var/log/gitlab 85 | - ./gitlab-post-reconfigure.sh:/etc/gitlab/post-reconfigure.sh:ro 86 | 87 | # The runners 88 | gitlab-runner-1: 89 | container_name: ${DEMO_NAME}-gitlab-runner-1 90 | depends_on: 91 | - gitlab 92 | hostname: gitlab-runner 93 | image: gitlab/gitlab-runner:latest 94 | restart: unless-stopped 95 | volumes: 96 | - gitlab_runner_config_1:/etc/gitlab-runner 97 | - /var/run/docker.sock:/var/run/docker.sock 98 | - runner_cache:/srv/cache:z 99 | 100 | gitlab-runner-2: 101 | container_name: ${DEMO_NAME}-gitlab-runner-2 102 | depends_on: 103 | - gitlab 104 | hostname: gitlab-runner-2 105 | image: gitlab/gitlab-runner:latest 106 | restart: unless-stopped 107 | volumes: 108 | - gitlab_runner_config_2:/etc/gitlab-runner 109 | - /var/run/docker.sock:/var/run/docker.sock 110 | - runner_cache:/srv/cache:z 111 | 112 | # SonarQube 113 | sonarqube: 114 | container_name: ${DEMO_NAME}-sonarqube 115 | image: sonarqube:${SONARQUBE_VERSION} 116 | ports: 117 | - "127.0.0.1:${SONARQUBE_PORT}:9000" 118 | restart: unless-stopped 119 | stop_grace_period: 10m 120 | volumes: 121 | - sonarqube_config:/opt/sonarqube/conf 122 | - sonarqube_data:/opt/sonarqube/data 123 | - sonarqube_extensions:/opt/sonarqube/extensions 124 | - sonarqube_logs:/opt/sonarqube/logs 125 | - sonarqube_temp:/opt/sonarqube/temp 126 | 127 | # Dependency-Track web interface 128 | dtrack-frontend: 129 | image: dependencytrack/frontend:${DTRACK_FRONTEND_VERSION} 130 | depends_on: 131 | - dtrack-apiserver 132 | environment: 133 | - API_BASE_URL=http://${DTRACK_HOSTNAME}:${DTRACK_API_PORT} 134 | ports: 135 | - "127.0.0.1:${DTRACK_FRONTEND_PORT}:8080" 136 | restart: unless-stopped 137 | 138 | # Dependency-Track API server 139 | dtrack-apiserver: 140 | image: dependencytrack/apiserver:${DTRACK_API_VERSION} 141 | deploy: 142 | resources: 143 | limits: 144 | memory: 12288m 145 | reservations: 146 | memory: 8192m 147 | ports: 148 | - "127.0.0.1:${DTRACK_API_PORT}:8080" 149 | volumes: 150 | - dependency-track:/data 151 | restart: unless-stopped 152 | -------------------------------------------------------------------------------- /env-example: -------------------------------------------------------------------------------- 1 | DEMO_NAME=my-demo 2 | DIND_VERSION=28.1.1-dind 3 | DTRACK_API_PORT=8081 4 | DTRACK_API_VERSION=4.13.0 5 | DTRACK_FRONTEND_PORT=5080 6 | DTRACK_FRONTEND_VERSION=4.13.0 7 | DTRACK_HOSTNAME=localhost 8 | DTRACK_PASSWORD=dependencytrack 9 | GITLAB_HOSTNAME=localhost 10 | GITLAB_PASSWORD=minimmm-12-COMPLXX 11 | GITLAB_PORT=6080 12 | GITLAB_SSH=7722 13 | GITLAB_VERSION=17.11.0-ce.0 14 | SONARQUBE_HOSTNAME=localhost 15 | SONARQUBE_PASSWORD=sonarqube 16 | SONARQUBE_PORT=9000 17 | SONARQUBE_PLUGINS="https://github.com/dependency-check/dependency-check-sonar-plugin/releases/download/5.0.0/sonar-dependency-check-plugin-5.0.0.jar https://github.com/green-code-initiative/ecoCode-python/releases/download/1.5.0/ecocode-python-plugin-1.5.0.jar https://github.com/olivierboudet/grype-sonar-plugin/releases/download/v1.1.0/grype-sonar-plugin-1.1.0.jar https://github.com/sbaudoin/sonar-shellcheck/releases/download/v2.5.0/sonar-shellcheck-plugin-2.5.0.jar https://github.com/sbaudoin/sonar-yaml/releases/download/v1.9.1/sonar-yaml-plugin-1.9.1.jar" 18 | SONARQUBE_VERSION=lts-community -------------------------------------------------------------------------------- /gitlab-post-reconfigure.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Configure some basic GitLab parts 4 | # Part of https://github.com/PeterMosmans/gitlab-demolab 5 | # 6 | # Copyright (C) 2022-2024 Peter Mosmans [Go Forward] 7 | # SPDX-License-Identifier: GPL-3.0-or-later 8 | 9 | set -e 10 | gitlab-rails runner 'ApplicationSetting.last.update(signup_enabled: false)' 11 | echo "Post Reconfigure Script successfully executed" 12 | -------------------------------------------------------------------------------- /installer.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright (C) 2022-2024 Peter Mosmans [Go Forward] 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | # Start up GitLab and several demo services. 6 | # Part of https://github.com/PeterMosmans/gitlab-demolab 7 | 8 | # When executing without parameters, only start (and configure) GitLab 9 | # The following arguments are recognized: 10 | # all Start (and configure) all services: GitLab, Dependency-Track and SonarQube 11 | # sonarqube Start (and configure) SonarQube 12 | # dependency-track Start (and configure) Dependency-Track 13 | # stop Stop all services 14 | # remove Stop all services and remove all volumes 15 | 16 | set -u 17 | 18 | COL_BOLD="\033[1m" 19 | COL_GREEN="\033[32m" 20 | COL_RED="\033[0;31m" 21 | COL_RESET="\033[0m" 22 | COL_YELLOW="\033[0;33m" 23 | 24 | COMPOSE=$(which docker-compose) 25 | compose_file="docker-compose.yml" 26 | 27 | setup() { 28 | # Check if there already is an .env file 29 | if [[ ! -f .env ]]; then 30 | echo -e "No ${COL_BOLD}.env${COL_RESET} file found, copying env-example file to create one ... " 31 | cp env-example .env 32 | echo -e "${COL_GREEN}Default .env file created${COL_RESET}" 33 | else 34 | echo -e "${COL_GREEN}Found existing .env file${COL_RESET}" 35 | fi 36 | 37 | # shellcheck disable=SC1091 38 | source .env 39 | } 40 | 41 | validate_hostnames() { 42 | if ! curl --version 1> /dev/null 2>&1; then 43 | echo -e "${COL_RED}curl is not installed - unable to verify the hostnames or change initial passwords${COL_RESET}" 44 | echo -e "Please install ${COL_BOLD}curl${COL_RESET} to prevent configuration issues" 45 | else 46 | for name in ${DTRACK_HOSTNAME} ${GITLAB_HOSTNAME} ${SONARQUBE_HOSTNAME}; do 47 | # Note that the port number doesn't matter - we're checking whether it can be resolved 48 | curl --silent "http://${name}:${GITLAB_PORT}/" --output /dev/null 1> /dev/null 2>&1 49 | exitcode=$? 50 | if ((exitcode == 6)); then 51 | echo -e "${COL_RED}$name could not be resolved${COL_RESET}: Please check your hosts file or edit the .env file" 52 | fi 53 | done 54 | fi 55 | } 56 | 57 | wait_for_gitlab() { 58 | echo -n "Waiting on GitLab to initialize ... " 59 | while [[ $( 60 | "$COMPOSE" -f "$compose_file" logs gitlab 2> /dev/null | grep -q "Server initialized" 61 | echo $? 62 | ) -ne 0 ]]; do 63 | sleep 1 64 | done 65 | echo -e "${COL_GREEN}done${COL_RESET}" 66 | echo -n "Waiting on GitLab to come up online ... " 67 | while [[ $(curl --silent -o /dev/null -w '%{http_code}\n' -X HEAD "http://${GITLAB_HOSTNAME}:${GITLAB_PORT}/users/sign_in") -ne 200 ]]; do 68 | sleep 1 69 | done 70 | echo -e "${COL_GREEN}done${COL_RESET}" 71 | echo -e "You can now log in to GitLab at ${COL_BOLD}http://${GITLAB_HOSTNAME}:${GITLAB_PORT}${COL_RESET} as ${COL_BOLD}root${COL_RESET} using password ${COL_BOLD}${GITLAB_PASSWORD}${COL_RESET}" 72 | echo "If you haven't done already: Don't forget to create a runner token and register the runners manually" 73 | echo "Usage: ./register-runners.sh TOKEN" 74 | } 75 | 76 | start_dependency-track() { 77 | echo -e "Starting ${COL_BOLD}Dependency-Track${COL_RESET}" 78 | "$COMPOSE" -f "$compose_file" up --detach dtrack-apiserver dtrack-frontend 79 | echo -n "Waiting on Dependency-Track to come up online ... " 80 | while [[ $( 81 | "$COMPOSE" -f "$compose_file" logs dtrack-frontend 2> /dev/null | grep -q "Configuration complete" 82 | echo $? 83 | ) -ne 0 ]]; do 84 | sleep 1 85 | done 86 | echo -e "${COL_GREEN}done${COL_RESET}" 87 | status_code=$(curl --silent -o /dev/null -w '%{http_code}\n' -d "username=admin" -d "password=admin" -d "newPassword=${DTRACK_PASSWORD}" -d "confirmPassword=${DTRACK_PASSWORD}" \ 88 | "http://${DTRACK_HOSTNAME}:${DTRACK_API_PORT}/api/v1/user/forceChangePassword") 89 | if [ "$status_code" -eq 200 ]; then 90 | echo -e "Changed default ${COL_BOLD}admin${COL_RESET} password to ${COL_BOLD}${DTRACK_PASSWORD}${COL_RESET}" 91 | fi 92 | echo -e "You now can log in to Dependency-Track at ${COL_BOLD}http://${DTRACK_HOSTNAME}:${DTRACK_FRONTEND_PORT}${COL_RESET}" 93 | } 94 | 95 | start_gitlab() { 96 | echo -e "Starting ${COL_BOLD}GitLab${COL_RESET}" 97 | "$COMPOSE" -f "$compose_file" up --detach gitlab gitlab-runner-1 gitlab-runner-2 98 | } 99 | 100 | configure_sonarqube() { 101 | status_code=$(curl --silent -o /dev/null -w '%{http_code}\n' -u admin:admin -X POST "http://${SONARQUBE_HOSTNAME}:${SONARQUBE_PORT}/api/users/change_password?login=admin&previousPassword=admin&password=${SONARQUBE_PASSWORD}") 102 | if [ "$status_code" -eq 204 ]; then 103 | echo -e "Changed the default ${COL_BOLD}admin${COL_RESET} password to ${SONARQUBE_PASSWORD}" 104 | echo "Installing the following plugins: ${SONARQUBE_PLUGINS}" 105 | # shellcheck disable=SC2140 106 | "$COMPOSE" -f "$compose_file" exec sonarqube /bin/bash -c "for plugin in ${SONARQUBE_PLUGINS}; do wget --directory-prefix /opt/sonarqube/extensions/plugins/ -L "\$plugin"; done" 107 | echo "Restarting SonarQube" 108 | "$COMPOSE" -f "$compose_file" restart sonarqube 109 | fi 110 | } 111 | 112 | start_sonarqube() { 113 | echo -e "Starting ${COL_BOLD}SonarQube${COL_RESET}" 114 | "$COMPOSE" -f "$compose_file" up --detach sonarqube 115 | echo -n "Waiting on SonarQube to come up online ... " 116 | while [[ $( 117 | "$COMPOSE" -f "$compose_file" logs sonarqube 2> /dev/null | grep -q "SonarQube is operational" 118 | echo $? 119 | ) -ne 0 ]]; do 120 | sleep 1 121 | done 122 | echo -e "${COL_GREEN}done${COL_RESET}" 123 | configure_sonarqube 124 | echo -e "You now can log in to SonarQube at ${COL_BOLD}http://${SONARQUBE_HOSTNAME}:${SONARQUBE_PORT}${COL_RESET}" 125 | } 126 | 127 | # Fix permissions on named volume: We want all tools to be able to use it 128 | fix_permissions() { 129 | docker run --rm -it -v "${DEMO_NAME}-runner_cache:/srv/cache:z" busybox /bin/sh -c "chmod o+rwx /srv/cache/" 130 | } 131 | 132 | # Stop all services and exit 133 | stop_services() { 134 | echo "Stopping all services" 135 | "$COMPOSE" -f "$compose_file" stop 136 | exit 0 137 | } 138 | 139 | # Stop all services and remove all volumes 140 | remove_services() { 141 | echo "Stopping and removing all services" 142 | "$COMPOSE" -f "$compose_file" down --volumes 2> /dev/null 143 | exit 0 144 | } 145 | 146 | (($# > 0)) && [[ $1 == stop ]] && stop_services 147 | (($# > 0)) && [[ $1 == remove ]] && remove_services 148 | if (($# > 0)) && [[ $1 != all ]] && [[ $1 != dependency-track ]] && [[ $1 != sonarqube ]]; then 149 | echo -e "${COL_RED}Unknown option${COL_RESET} - this program only understands the following options:" 150 | echo "(no options) Start GitLab" 151 | echo -e "${COL_YELLOW}dependency-track${COL_RESET} Start Dependency-Track (and GitLab)" 152 | echo -e "${COL_YELLOW}sonarqube${COL_RESET} Start SonarQube (and GitLab)" 153 | echo -e "${COL_YELLOW}all${COL_RESET} Start Dependency-Track, SonarQube, and GitLab" 154 | echo -e "${COL_YELLOW}stop${COL_RESET} Stop all started services" 155 | echo -e "${COL_YELLOW}remove${COL_RESET} Stop started services and remove volumes" 156 | exit 1 157 | fi 158 | 159 | setup 160 | validate_hostnames 161 | start_gitlab 162 | if (($# > 0)); then 163 | [[ $1 == all ]] || [[ $1 == dependency-track ]] && start_dependency-track 164 | [[ $1 == all ]] || [[ $1 == sonarqube ]] && start_sonarqube 165 | fi 166 | 167 | fix_permissions 168 | wait_for_gitlab 169 | -------------------------------------------------------------------------------- /juice-shop/build-pipeline/.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # SPDX-License-Identifier: GPL-3.0-or-later 3 | # (c) 2020-2024 Peter Mosmans [Go Forward] 4 | 5 | # Pipeline template for automated security testing 6 | 7 | ### Variables used throughout the pipeline 8 | 9 | variables: 10 | # These variables will be used throughout the pipeline, in all jobs 11 | # By default, the repository will not be used; artifacts will 12 | GIT_STRATEGY: none 13 | IMAGE_TAG: ${CI_COMMIT_SHORT_SHA} 14 | IMAGE_TAR: ${IMAGE_TAG}.tar 15 | 16 | ### Include several jobs 17 | 18 | include: 19 | # build 20 | - .gitlab/docker-build.gitlab-ci.yml 21 | 22 | ### Pipeline stages 23 | 24 | stages: 25 | # Build the artifact 26 | - build 27 | 28 | ### Jobs 29 | 30 | # All jobs that start with a dot are templates and can be extended. 31 | 32 | .build: 33 | stage: build 34 | # No artifacts from previous stages are required 35 | dependencies: [] 36 | # Ensure a "clean" build environment 37 | variables: 38 | GIT_DEPTH: 1 39 | GIT_STRATEGY: clone 40 | -------------------------------------------------------------------------------- /juice-shop/build-pipeline/.gitlab/docker-build.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # SPDX-License-Identifier: GPL-3.0-or-later 3 | # (c) 2020-2024 Peter Mosmans [Go Forward] 4 | # 5 | # Builds a Docker image and stores the Docker image as tar file 6 | # 7 | # Variables: 8 | # IMAGE_TAG Docker image tag 9 | # IMAGE_TAR Name of the Docker image in tar format 10 | 11 | build: 12 | extends: .build 13 | script: 14 | - > 15 | DOCKER_BUILDKIT=1 docker build -t ${IMAGE_TAG} . ; 16 | docker save ${IMAGE_TAG} > ${IMAGE_TAR} 17 | artifacts: 18 | expire_in: 1 week 19 | name: "$CI_JOB_NAME artifacts from $CI_PROJECT_NAME on $CI_COMMIT_REF_SLUG" 20 | when: always 21 | paths: 22 | - ${IMAGE_TAR} 23 | -------------------------------------------------------------------------------- /juice-shop/dependency-check/.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # SPDX-License-Identifier: GPL-3.0-or-later 3 | # (c) 2020-2024 Peter Mosmans [Go Forward] 4 | 5 | # Pipeline template for automated security testing 6 | 7 | ### Variables used throughout the pipeline 8 | 9 | variables: 10 | # These variables will be used throughout the pipeline, in all jobs 11 | # Generic cache directory 12 | CACHE_DIR: /srv/cache 13 | # By default, the repository will not be used; artifacts will 14 | GIT_STRATEGY: none 15 | IMAGE_TAG: ${CI_COMMIT_SHORT_SHA} 16 | IMAGE_TAR: ${IMAGE_TAG}.tar 17 | # Tool-specific: Image versions 18 | DEPENDENCY_VERSION: 12.1.1 19 | HADOLINT_VERSION: v2.12.0-debian 20 | NJSSCAN_VERSION: 0.4.3 21 | TOOLS_VERSION: 1.8.0 22 | 23 | ### Include several jobs 24 | 25 | include: 26 | # .pre 27 | - .gitlab/detect-secrets.gitlab-ci.yml 28 | # sast 29 | - .gitlab/hadolint.gitlab-ci.yml 30 | # sast 31 | - .gitlab/njsscan.gitlab-ci.yml 32 | # sast 33 | - .gitlab/sonarqube.gitlab-ci.yml 34 | # build 35 | - .gitlab/docker-build.gitlab-ci.yml 36 | # security 37 | - .gitlab/dependency-check.gitlab-ci.yml 38 | 39 | ### Pipeline stages 40 | 41 | stages: 42 | # Security checks over source code, can be performed parallel to building 43 | - sast 44 | # Build the artifact 45 | - build 46 | # (Dynamic) security checks using / over build artifact 47 | - security 48 | 49 | ### Jobs 50 | 51 | # All jobs that start with a dot are templates and can be extended. 52 | 53 | .sast: 54 | stage: sast 55 | # No artifacts from previous stages are required 56 | dependencies: [] 57 | # Source code is necessary 58 | variables: 59 | GIT_DEPTH: 1 60 | GIT_STRATEGY: fetch 61 | # Run after the detect-secrets job finishes 62 | needs: 63 | - detect-secrets 64 | 65 | .build: 66 | stage: build 67 | # No artifacts from previous stages are required 68 | dependencies: [] 69 | # Ensure a "clean" build environment 70 | variables: 71 | GIT_DEPTH: 1 72 | GIT_STRATEGY: clone 73 | # Run after detect-secrets ran successfully 74 | needs: 75 | - detect-secrets 76 | 77 | .security: 78 | stage: security 79 | needs: 80 | - build 81 | -------------------------------------------------------------------------------- /juice-shop/dependency-check/.gitlab/dependency-check.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # SPDX-License-Identifier: GPL-3.0-or-later 3 | # (c) 2020-2024 Peter Mosmans [Go Forward] 4 | # 5 | # Detects whether outdated and insecure libraries are in use by running Dependency-Check. 6 | # 7 | # If the Dependency-Check suppression file exists, use it. 8 | # 9 | # Variables: 10 | # CACHE_DIR General cache directory 11 | # DEPENDENCY_SUPPRESSION Suppression file for Dependency-Check 12 | # DEPENDENCY_VERSION Specifies which version of owasp/dependency-check is being used 13 | 14 | # NVD_KEY NVD API Key (optional) 15 | 16 | dependency-check: 17 | # Ensure a "clean" scan environment 18 | variables: 19 | GIT_DEPTH: 1 20 | GIT_STRATEGY: clone 21 | DEPENDENCY_SUPPRESSION: "suppression.xml" 22 | extends: .security 23 | image: 24 | name: owasp/dependency-check:${DEPENDENCY_VERSION} 25 | entrypoint: [""] 26 | before_script: 27 | - mkdir -p reports &>/dev/null || true 28 | - mkdir -p ${CACHE_DIR}/dependency-check || true 29 | script: 30 | - > 31 | if [[ -f "${DEPENDENCY_SUPPRESSION}" ]] ; then 32 | EXTRA_PARMS="--suppression ${DEPENDENCY_SUPPRESSION}" ; 33 | else 34 | EXTRA_PARMS="" ; 35 | fi ; 36 | if [[ -n "${NVD_KEY}" ]]; then 37 | EXTRA_PARMS="${EXTRA_PARMS} --nvdApiKey ${NVD_KEY}"; 38 | fi ; 39 | /usr/share/dependency-check/bin/dependency-check.sh 40 | --enableExperimental 41 | --exclude "**/*.tgz" 42 | --exclude "**/*.zip" 43 | --failOnCVSS 6 44 | --format HTML 45 | --format JSON 46 | --format SARIF 47 | --out reports 48 | --project ${CI_PROJECT_NAME} 49 | --data ${CACHE_DIR}/dependency-check 50 | --scan . ${EXTRA_PARMS} 51 | artifacts: 52 | name: "$CI_JOB_NAME artifacts from $CI_PROJECT_NAME on $CI_COMMIT_REF_SLUG" 53 | when: always 54 | paths: 55 | - reports/dependency-check-report.* 56 | # Only flag the job as failed, not the whole pipeline 57 | allow_failure: true 58 | -------------------------------------------------------------------------------- /juice-shop/dependency-track/.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # SPDX-License-Identifier: GPL-3.0-or-later 3 | # (c) 2020-2024 Peter Mosmans [Go Forward] 4 | 5 | # Pipeline template for automated security testing 6 | 7 | ### Variables used throughout the pipeline 8 | 9 | variables: 10 | # These variables will be used throughout the pipeline, in all jobs 11 | # Generic cache directory 12 | CACHE_DIR: /srv/cache 13 | # By default, the repository will not be used; artifacts will 14 | GIT_STRATEGY: none 15 | IMAGE_TAG: ${CI_COMMIT_SHORT_SHA} 16 | IMAGE_TAR: ${IMAGE_TAG}.tar 17 | # Tool-specific: Image versions 18 | DEPENDENCY_VERSION: 12.1.1 19 | HADOLINT_VERSION: v2.12.0-debian 20 | NJSSCAN_VERSION: 0.4.3 21 | TOOLS_VERSION: 1.8.0 22 | 23 | ### Include several jobs 24 | 25 | include: 26 | # .pre 27 | - .gitlab/detect-secrets.gitlab-ci.yml 28 | # sast 29 | - .gitlab/hadolint.gitlab-ci.yml 30 | # sast 31 | - .gitlab/njsscan.gitlab-ci.yml 32 | # sast 33 | - .gitlab/sonarqube.gitlab-ci.yml 34 | # build 35 | - .gitlab/docker-build.gitlab-ci.yml 36 | # security 37 | - .gitlab/dependency-check.gitlab-ci.yml 38 | # security 39 | - .gitlab/dependency-track.gitlab-ci.yml 40 | 41 | ### Pipeline stages 42 | 43 | stages: 44 | # Security checks over source code, can be performed parallel to building 45 | - sast 46 | # Build the artifact 47 | - build 48 | # (Dynamic) security checks using / over build artifact 49 | - security 50 | 51 | ### Jobs 52 | 53 | # All jobs that start with a dot are templates and can be extended. 54 | 55 | .sast: 56 | stage: sast 57 | # No artifacts from previous stages are required 58 | dependencies: [] 59 | # Source code is necessary 60 | variables: 61 | GIT_DEPTH: 1 62 | GIT_STRATEGY: fetch 63 | # Run after the detect-secrets job finishes 64 | needs: 65 | - detect-secrets 66 | 67 | .build: 68 | stage: build 69 | # No artifacts from previous stages are required 70 | dependencies: [] 71 | # Ensure a "clean" build environment 72 | variables: 73 | GIT_DEPTH: 1 74 | GIT_STRATEGY: clone 75 | # Run after detect-secrets ran successfully 76 | needs: 77 | - detect-secrets 78 | 79 | .security: 80 | stage: security 81 | needs: 82 | - build 83 | -------------------------------------------------------------------------------- /juice-shop/dependency-track/.gitlab/dependency-track.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # SPDX-License-Identifier: GPL-3.0-or-later 3 | # (c) 2020-2024 Peter Mosmans [Go Forward] 4 | # 5 | # Uploads SBOM files to a Dependency-Track server. 6 | # 7 | # Variables: 8 | # DTRACK_KEY Dependency-Track access token (API key) 9 | # DTRACK_URL Location of Dependency-Track API server 10 | # TOOLS_VERSION Specifies which version of gofwd/tools-image is being used 11 | 12 | dependency-track: 13 | extends: .security 14 | # This job only needs curl 15 | image: 16 | name: gofwd/tools-image:${TOOLS_VERSION} 17 | entrypoint: [""] 18 | script: 19 | - > 20 | curl "${DTRACK_URL}api/v1/bom" 21 | -H "X-Api-Key: ${DTRACK_KEY}" 22 | -F "autoCreate=true" 23 | -F "projectName=${CI_PROJECT_TITLE}-backend" 24 | -F "bom=@bom-backend.json" 25 | - > 26 | curl "${DTRACK_URL}api/v1/bom" 27 | -H "X-Api-Key: ${DTRACK_KEY}" 28 | -F "autoCreate=true" 29 | -F "projectName=${CI_PROJECT_TITLE}-frontend" 30 | -F "bom=@bom-frontend.json" 31 | rules: 32 | - if: "$DTRACK_KEY != null" 33 | when: on_success 34 | -------------------------------------------------------------------------------- /juice-shop/dependency-track/.gitlab/docker-build.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # SPDX-License-Identifier: GPL-3.0-or-later 3 | # (c) 2020-2024 Peter Mosmans [Go Forward] 4 | # 5 | # Builds a Docker image and stores the Docker image as tar file, as well as SBOMs. 6 | # 7 | # Variables: 8 | # IMAGE_TAG Docker image tag 9 | # IMAGE_TAR Name of the Docker image in tar format 10 | 11 | build: 12 | extends: .build 13 | script: 14 | - > 15 | DOCKER_BUILDKIT=1 docker build -t ${IMAGE_TAG} . ; 16 | docker save ${IMAGE_TAG} > ${IMAGE_TAR} ; 17 | temp_container=$(docker create ${IMAGE_TAG}) ; 18 | docker cp "$temp_container:/juice-shop/bom.json" bom-backend.json ; 19 | docker cp "$temp_container:/juice-shop/frontend/dist/bom/bom.json" bom-frontend.json ; 20 | docker rm "$temp_container" 21 | artifacts: 22 | expire_in: 1 week 23 | name: "$CI_JOB_NAME artifacts from $CI_PROJECT_NAME on $CI_COMMIT_REF_SLUG" 24 | when: always 25 | paths: 26 | - ${IMAGE_TAR} 27 | - bom-*.json 28 | -------------------------------------------------------------------------------- /juice-shop/detect-secrets/.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # SPDX-License-Identifier: GPL-3.0-or-later 3 | # (c) 2020-2024 Peter Mosmans [Go Forward] 4 | 5 | # Pipeline template for automated security testing 6 | 7 | ### Variables used throughout the pipeline 8 | 9 | variables: 10 | # These variables will be used throughout the pipeline, in all jobs 11 | # By default, the repository will not be used; artifacts will 12 | GIT_STRATEGY: none 13 | IMAGE_TAG: ${CI_COMMIT_SHORT_SHA} 14 | IMAGE_TAR: ${IMAGE_TAG}.tar 15 | # Tool-specific: Image versions 16 | TOOLS_VERSION: 1.8.0 17 | 18 | ### Include several jobs 19 | 20 | include: 21 | # .pre 22 | - .gitlab/detect-secrets.gitlab-ci.yml 23 | # build 24 | - .gitlab/docker-build.gitlab-ci.yml 25 | 26 | ### Pipeline stages 27 | 28 | stages: 29 | # Build the artifact 30 | - build 31 | 32 | ### Jobs 33 | 34 | # All jobs that start with a dot are templates and can be extended. 35 | 36 | .build: 37 | stage: build 38 | # No artifacts from previous stages are required 39 | dependencies: [] 40 | # Ensure a "clean" build environment 41 | variables: 42 | GIT_DEPTH: 1 43 | GIT_STRATEGY: clone 44 | # Run after the detect-secrets job finishes 45 | needs: 46 | - detect-secrets 47 | -------------------------------------------------------------------------------- /juice-shop/detect-secrets/.gitlab/detect-secrets.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # SPDX-License-Identifier: GPL-3.0-or-later 3 | # (c) 2020-2024 Peter Mosmans [Go Forward] 4 | # 5 | # Detects secrets in modified files. 6 | # 7 | # Note that this tool expects the file BASELINE to be present in the root 8 | # directory. If not, the job will fail. 9 | # 10 | # Variables: 11 | # BASELINE The baseline file of detect-secrets 12 | # TOOLS_VERSION Specifies which version of gofwd/tools-image is being used 13 | 14 | detect-secrets: 15 | stage: .pre 16 | image: gofwd/tools-image:${TOOLS_VERSION} 17 | variables: 18 | GIT_STRATEGY: clone 19 | BASELINE: .secrets.baseline 20 | before_script: 21 | - > 22 | if [[ ! -f "${BASELINE}" ]]; then 23 | echo "The file ${BASELINE} does not exist"; 24 | echo "Make sure to create and upload this first... exiting" ; 25 | exit 1 ; 26 | fi 27 | - > 28 | git config --global --add safe.directory ${CI_PROJECT_DIR} ; 29 | git checkout ${CI_COMMIT_BRANCH} -- ; 30 | mkdir -p reports &>/dev/null || true 31 | script: 32 | - > 33 | if [ "$CI_COMMIT_BEFORE_SHA" = "0000000000000000000000000000000000000000" ] ; 34 | then 35 | COMMIT_BEFORE_SHA=$(git rev-parse HEAD~1) ; 36 | else 37 | COMMIT_BEFORE_SHA=$CI_COMMIT_BEFORE_SHA ; 38 | fi; 39 | echo "Checking files between ${COMMIT_BEFORE_SHA} and ${CI_COMMIT_BEFORE_SHA}" ; 40 | echo "Checking the following files for secrets: 41 | $(git diff --name-only --diff-filter=d $COMMIT_BEFORE_SHA $CI_COMMIT_SHA)" ; 42 | git diff --name-only --diff-filter=d $COMMIT_BEFORE_SHA $CI_COMMIT_SHA | 43 | xargs detect-secrets-hook --baseline ${BASELINE} > reports/detect-secrets-report.txt 44 | # Always show report 45 | after_script: 46 | - cat reports/detect-secrets-report.txt 47 | artifacts: 48 | name: "$CI_JOB_NAME artifacts from $CI_PROJECT_NAME on $CI_COMMIT_REF_SLUG" 49 | when: always 50 | paths: 51 | - reports/detect-secrets-report.txt 52 | -------------------------------------------------------------------------------- /juice-shop/full-testing/.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # SPDX-License-Identifier: GPL-3.0-or-later 3 | # (c) 2020-2024 Peter Mosmans [Go Forward] 4 | 5 | # Pipeline template for automated security testing 6 | 7 | ### Variables used throughout the pipeline 8 | 9 | variables: 10 | # These variables will be used throughout the pipeline, in all jobs 11 | # Generic cache directory 12 | CACHE_DIR: /srv/cache 13 | # By default, the repository will not be used; artifacts will 14 | GIT_STRATEGY: none 15 | IMAGE_TAG: ${CI_COMMIT_SHORT_SHA} 16 | IMAGE_TAR: ${IMAGE_TAG}.tar 17 | # Tool-specific: Image versions 18 | DEPENDENCY_VERSION: 12.1.1 19 | HADOLINT_VERSION: v2.12.0-debian 20 | NJSSCAN_VERSION: 0.4.3 21 | TOOLS_VERSION: 1.8.0 22 | TRIVY_VERSION: 0.61.1 23 | ZAP_VERSION: 2.16.1 24 | 25 | ### Include several jobs 26 | 27 | include: 28 | # .pre 29 | - .gitlab/detect-secrets.gitlab-ci.yml 30 | # sast 31 | - .gitlab/hadolint.gitlab-ci.yml 32 | # sast 33 | - .gitlab/njsscan.gitlab-ci.yml 34 | # security 35 | - .gitlab/sonarqube.gitlab-ci.yml 36 | # build 37 | - .gitlab/docker-build.gitlab-ci.yml 38 | # security 39 | - .gitlab/dependency-check.gitlab-ci.yml 40 | # security 41 | - .gitlab/dependency-track.gitlab-ci.yml 42 | # security 43 | - .gitlab/trivy.gitlab-ci.yml 44 | # security 45 | - .gitlab/zap.gitlab-ci.yml 46 | # security 47 | - .gitlab/nikto.gitlab-ci.yml 48 | 49 | ### Pipeline stages 50 | 51 | stages: 52 | # Security checks over source code, can be performed parallel to building 53 | - sast 54 | # Build the artifact 55 | - build 56 | # (Dynamic) security checks using / over build artifact 57 | - security 58 | 59 | ### Jobs 60 | 61 | # All jobs that start with a dot are templates and can be extended. 62 | 63 | .sast: 64 | stage: sast 65 | # No artifacts from previous stages are required 66 | dependencies: [] 67 | # Source code is necessary 68 | variables: 69 | GIT_DEPTH: 1 70 | GIT_STRATEGY: fetch 71 | # Run after the detect-secrets job finishes 72 | needs: 73 | - detect-secrets 74 | 75 | .build: 76 | stage: build 77 | # No artifacts from previous stages are required 78 | dependencies: [] 79 | # Ensure a "clean" build environment 80 | variables: 81 | GIT_DEPTH: 1 82 | GIT_STRATEGY: clone 83 | # Run after detect-secrets ran successfully 84 | needs: 85 | - detect-secrets 86 | 87 | .security: 88 | stage: security 89 | needs: 90 | - build 91 | -------------------------------------------------------------------------------- /juice-shop/full-testing/.gitlab/sonarqube.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # SPDX-License-Identifier: GPL-3.0-or-later 3 | # (c) 2020-2024 Peter Mosmans [Go Forward] 4 | # 5 | # Executes SonarScanner and uploads results to SonarQube. 6 | # 7 | # Variables: 8 | # SONAR_TOKEN SonarQube access token 9 | # SONAR_URL Location of SonarQube 10 | # TOOLS_VERSION Specifies which version of gofwd/tools-image is being used 11 | 12 | sonarqube: 13 | extends: .security 14 | # If external test results are included, their artifacts are required 15 | needs: 16 | - dependency-check 17 | - hadolint 18 | - njsscan 19 | - trivy 20 | - zap 21 | variables: 22 | GIT_DEPTH: 1 23 | GIT_STRATEGY: fetch 24 | SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" 25 | image: 26 | name: gofwd/tools-image:${TOOLS_VERSION} 27 | entrypoint: [""] 28 | cache: 29 | key: "${CI_JOB_NAME}" 30 | paths: 31 | - .sonar/cache 32 | script: 33 | - > 34 | sonar-scanner 35 | -Dsonar.dependencyCheck.htmlReportPath=reports/dependency-check-report.html 36 | -Dsonar.dependencyCheck.jsonReportPath=reports/dependency-check-report.json 37 | -Dsonar.docker.hadolint.reportPaths=reports/hadolint-report.json 38 | -Dsonar.exclusions=reports/** 39 | -Dsonar.externalIssuesReportPaths=reports/njsscan-report.json 40 | -Dsonar.host.url=${SONAR_URL} 41 | -Dsonar.path.temp=${RUNNER_TEMP_PROJECT_DIR} 42 | -Dsonar.projectKey=${CI_PROJECT_TITLE} 43 | -Dsonar.sarifReportPaths=reports/zap-report.sarif.json,reports/trivy-report.sarif.json,reports/dependency-check-report.sarif 44 | rules: 45 | - if: "$SONAR_TOKEN != null" 46 | when: always 47 | -------------------------------------------------------------------------------- /juice-shop/hadolint/.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # SPDX-License-Identifier: GPL-3.0-or-later 3 | # (c) 2020-2024 Peter Mosmans [Go Forward] 4 | 5 | # Pipeline template for automated security testing 6 | 7 | ### Variables used throughout the pipeline 8 | 9 | variables: 10 | # These variables will be used throughout the pipeline, in all jobs 11 | # By default, the repository will not be used; artifacts will 12 | GIT_STRATEGY: none 13 | IMAGE_TAG: ${CI_COMMIT_SHORT_SHA} 14 | IMAGE_TAR: ${IMAGE_TAG}.tar 15 | # Tool-specific: Image versions 16 | HADOLINT_VERSION: v2.12.0-debian 17 | TOOLS_VERSION: 1.8.0 18 | 19 | ### Include several jobs 20 | 21 | include: 22 | # .pre 23 | - .gitlab/detect-secrets.gitlab-ci.yml 24 | # sast 25 | - .gitlab/hadolint.gitlab-ci.yml 26 | # build 27 | - .gitlab/docker-build.gitlab-ci.yml 28 | 29 | ### Pipeline stages 30 | 31 | stages: 32 | # Security checks over source code, can be performed parallel to building 33 | - sast 34 | # Build the artifact 35 | - build 36 | 37 | ### Jobs 38 | 39 | # All jobs that start with a dot are templates and can be extended. 40 | 41 | .sast: 42 | stage: sast 43 | # No artifacts from previous stages are required 44 | dependencies: [] 45 | # Source code is necessary 46 | variables: 47 | GIT_DEPTH: 1 48 | GIT_STRATEGY: fetch 49 | # Run after the detect-secrets job finishes 50 | needs: 51 | - detect-secrets 52 | 53 | .build: 54 | stage: build 55 | # No artifacts from previous stages are required 56 | dependencies: [] 57 | # Ensure a "clean" build environment 58 | variables: 59 | GIT_DEPTH: 1 60 | GIT_STRATEGY: clone 61 | # Run after detect-secrets ran successfully 62 | needs: 63 | - detect-secrets 64 | -------------------------------------------------------------------------------- /juice-shop/hadolint/.gitlab/hadolint.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # SPDX-License-Identifier: GPL-3.0-or-later 3 | # (c) 2020-2024 Peter Mosmans [Go Forward] 4 | # 5 | # Lints a Dockerfile using hadolint. 6 | # Optional configuration will be read from .hadolint.yaml 7 | # 8 | # Variables: 9 | # HADOLINT_VERSION Specifies which version of hadolint/hadolint is being used 10 | 11 | hadolint: 12 | extends: .sast 13 | image: 14 | name: hadolint/hadolint:${HADOLINT_VERSION} 15 | before_script: 16 | - mkdir -p reports &>/dev/null || true 17 | variables: 18 | GIT_STRATEGY: fetch 19 | script: 20 | - > 21 | hadolint --no-fail Dockerfile > reports/hadolint-report.txt ; 22 | hadolint --failure-threshold warning -f sonarqube Dockerfile > reports/hadolint-report.json 23 | # Always show report 24 | after_script: 25 | - cat reports/hadolint-report.txt 26 | artifacts: 27 | name: "$CI_JOB_NAME artifacts from $CI_PROJECT_NAME on $CI_COMMIT_REF_SLUG" 28 | when: always 29 | paths: 30 | - reports/hadolint-report.* 31 | # Only flag the job as failed, not the whole pipeline 32 | allow_failure: true 33 | -------------------------------------------------------------------------------- /juice-shop/nikto/.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # SPDX-License-Identifier: GPL-3.0-or-later 3 | # (c) 2020-2024 Peter Mosmans [Go Forward] 4 | 5 | # Pipeline template for automated security testing 6 | 7 | ### Variables used throughout the pipeline 8 | 9 | variables: 10 | # These variables will be used throughout the pipeline, in all jobs 11 | # Generic cache directory 12 | CACHE_DIR: /srv/cache 13 | # By default, the repository will not be used; artifacts will 14 | GIT_STRATEGY: none 15 | IMAGE_TAG: ${CI_COMMIT_SHORT_SHA} 16 | IMAGE_TAR: ${IMAGE_TAG}.tar 17 | # Tool-specific: Image versions 18 | DEPENDENCY_VERSION: 12.1.1 19 | HADOLINT_VERSION: v2.12.0-debian 20 | NJSSCAN_VERSION: 0.4.3 21 | TOOLS_VERSION: 1.8.0 22 | TRIVY_VERSION: 0.61.1 23 | ZAP_VERSION: 2.16.1 24 | 25 | ### Include several jobs 26 | 27 | include: 28 | # .pre 29 | - .gitlab/detect-secrets.gitlab-ci.yml 30 | # sast 31 | - .gitlab/hadolint.gitlab-ci.yml 32 | # sast 33 | - .gitlab/njsscan.gitlab-ci.yml 34 | # sast 35 | - .gitlab/sonarqube.gitlab-ci.yml 36 | # build 37 | - .gitlab/docker-build.gitlab-ci.yml 38 | # security 39 | - .gitlab/dependency-check.gitlab-ci.yml 40 | # security 41 | - .gitlab/dependency-track.gitlab-ci.yml 42 | # security 43 | - .gitlab/trivy.gitlab-ci.yml 44 | # security 45 | - .gitlab/zap.gitlab-ci.yml 46 | # security 47 | - .gitlab/nikto.gitlab-ci.yml 48 | 49 | ### Pipeline stages 50 | 51 | stages: 52 | # Security checks over source code, can be performed parallel to building 53 | - sast 54 | # Build the artifact 55 | - build 56 | # (Dynamic) security checks using / over build artifact 57 | - security 58 | 59 | ### Jobs 60 | 61 | # All jobs that start with a dot are templates and can be extended. 62 | 63 | .sast: 64 | stage: sast 65 | # No artifacts from previous stages are required 66 | dependencies: [] 67 | # Source code is necessary 68 | variables: 69 | GIT_DEPTH: 1 70 | GIT_STRATEGY: fetch 71 | # Run after the detect-secrets job finishes 72 | needs: 73 | - detect-secrets 74 | 75 | .build: 76 | stage: build 77 | # No artifacts from previous stages are required 78 | dependencies: [] 79 | # Ensure a "clean" build environment 80 | variables: 81 | GIT_DEPTH: 1 82 | GIT_STRATEGY: clone 83 | # Run after detect-secrets ran successfully 84 | needs: 85 | - detect-secrets 86 | 87 | .security: 88 | stage: security 89 | needs: 90 | - build 91 | -------------------------------------------------------------------------------- /juice-shop/nikto/.gitlab/nikto.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # SPDX-License-Identifier: GPL-3.0-or-later 3 | # (c) 2020-2024 Peter Mosmans [Go Forward] 4 | # 5 | # Performs a web server scan using Nikto. 6 | 7 | # Variables: 8 | # IMAGE_TAG Docker image tag 9 | # TOOLS_VERSION Specifies which version of gofwd/tools-image is being used 10 | 11 | nikto: 12 | extends: .security 13 | image: 14 | name: gofwd/tools-image:${TOOLS_VERSION} 15 | entrypoint: [""] 16 | services: 17 | - name: $IMAGE_TAG 18 | alias: juice-shop 19 | before_script: 20 | - mkdir -p reports &>/dev/null || true 21 | - > 22 | curl --max-time 120 23 | --retry 60 24 | --retry-connrefused 25 | --retry-delay 5 26 | --fail 27 | --silent http://juice-shop:3000 >/dev/null || exit 1 28 | script: 29 | - > 30 | nikto.pl 31 | -ask no 32 | -nointeractive 33 | -output reports/nikto-report.html 34 | -Plugins '@@ALL;-sitefiles' 35 | -Tuning x7 36 | -host http://juice-shop:3000 > reports/nikto-report.txt 37 | # Always show report 38 | after_script: 39 | - cat reports/nikto-report.txt 40 | artifacts: 41 | name: "$CI_JOB_NAME artifacts from $CI_PROJECT_NAME on $CI_COMMIT_REF_SLUG" 42 | when: always 43 | paths: 44 | - reports/nikto-report.* 45 | # Only flag the job as failed, not the whole pipeline 46 | allow_failure: true 47 | -------------------------------------------------------------------------------- /juice-shop/njsscan/.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # SPDX-License-Identifier: GPL-3.0-or-later 3 | # (c) 2020-2024 Peter Mosmans [Go Forward] 4 | 5 | # Pipeline template for automated security testing 6 | 7 | ### Variables used throughout the pipeline 8 | 9 | variables: 10 | # These variables will be used throughout the pipeline, in all jobs 11 | # By default, the repository will not be used; artifacts will 12 | GIT_STRATEGY: none 13 | IMAGE_TAG: ${CI_COMMIT_SHORT_SHA} 14 | IMAGE_TAR: ${IMAGE_TAG}.tar 15 | # Tool-specific: Image versions 16 | HADOLINT_VERSION: v2.12.0-debian 17 | NJSSCAN_VERSION: 0.4.3 18 | TOOLS_VERSION: 1.8.0 19 | 20 | ### Include several jobs 21 | 22 | include: 23 | # .pre 24 | - .gitlab/detect-secrets.gitlab-ci.yml 25 | # sast 26 | - .gitlab/hadolint.gitlab-ci.yml 27 | # sast 28 | - .gitlab/njsscan.gitlab-ci.yml 29 | # build 30 | - .gitlab/docker-build.gitlab-ci.yml 31 | 32 | ### Pipeline stages 33 | 34 | stages: 35 | # Security checks over source code, can be performed parallel to building 36 | - sast 37 | # Build the artifact 38 | - build 39 | 40 | ### Jobs 41 | 42 | # All jobs that start with a dot are templates and can be extended. 43 | 44 | .sast: 45 | stage: sast 46 | # No artifacts from previous stages are required 47 | dependencies: [] 48 | # Source code is necessary 49 | variables: 50 | GIT_DEPTH: 1 51 | GIT_STRATEGY: fetch 52 | # Run after the detect-secrets job finishes 53 | needs: 54 | - detect-secrets 55 | 56 | .build: 57 | stage: build 58 | # No artifacts from previous stages are required 59 | dependencies: [] 60 | # Ensure a "clean" build environment 61 | variables: 62 | GIT_DEPTH: 1 63 | GIT_STRATEGY: clone 64 | # Run after detect-secrets ran successfully 65 | needs: 66 | - detect-secrets 67 | -------------------------------------------------------------------------------- /juice-shop/njsscan/.gitlab/njsscan.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # SPDX-License-Identifier: GPL-3.0-or-later 3 | # (c) 2020-2024 Peter Mosmans [Go Forward] 4 | # 5 | # Executes njsscan over source code. 6 | # 7 | # Variables: 8 | # NJSSCAN_VERSION Specifies which version of opensecurity/njsscan is being used 9 | 10 | njsscan: 11 | extends: .sast 12 | image: 13 | name: opensecurity/njsscan:${NJSSCAN_VERSION} 14 | entrypoint: [""] 15 | before_script: 16 | - mkdir -p reports &>/dev/null || true 17 | script: 18 | - > 19 | njsscan --output reports/njsscan-report.txt . ; 20 | njsscan --exit-warning --sonarqube --output reports/njsscan-report.json . 21 | # Always show report 22 | after_script: 23 | - cat reports/njsscan-report.txt 24 | artifacts: 25 | name: "$CI_JOB_NAME artifacts from $CI_PROJECT_NAME on $CI_COMMIT_REF_SLUG" 26 | when: always 27 | paths: 28 | - reports/njsscan-report.* 29 | # Only flag the job as failed, not the whole pipeline 30 | allow_failure: true 31 | -------------------------------------------------------------------------------- /juice-shop/sonarqube/.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # SPDX-License-Identifier: GPL-3.0-or-later 3 | # (c) 2020-2024 Peter Mosmans [Go Forward] 4 | 5 | # Pipeline template for automated security testing 6 | 7 | ### Variables used throughout the pipeline 8 | 9 | variables: 10 | # These variables will be used throughout the pipeline, in all jobs 11 | # By default, the repository will not be used; artifacts will 12 | GIT_STRATEGY: none 13 | IMAGE_TAG: ${CI_COMMIT_SHORT_SHA} 14 | IMAGE_TAR: ${IMAGE_TAG}.tar 15 | # Tool-specific: Image versions 16 | HADOLINT_VERSION: v2.12.0-debian 17 | NJSSCAN_VERSION: 0.4.3 18 | TOOLS_VERSION: 1.8.0 19 | 20 | ### Include several jobs 21 | 22 | include: 23 | # .pre 24 | - .gitlab/detect-secrets.gitlab-ci.yml 25 | # sast 26 | - .gitlab/hadolint.gitlab-ci.yml 27 | # sast 28 | - .gitlab/njsscan.gitlab-ci.yml 29 | # sast 30 | - .gitlab/sonarqube.gitlab-ci.yml 31 | # build 32 | - .gitlab/docker-build.gitlab-ci.yml 33 | 34 | ### Pipeline stages 35 | 36 | stages: 37 | # Security checks over source code, can be performed parallel to building 38 | - sast 39 | # Build the artifact 40 | - build 41 | 42 | ### Jobs 43 | 44 | # All jobs that start with a dot are templates and can be extended. 45 | 46 | .sast: 47 | stage: sast 48 | # No artifacts from previous stages are required 49 | dependencies: [] 50 | # Source code is necessary 51 | variables: 52 | GIT_DEPTH: 1 53 | GIT_STRATEGY: fetch 54 | # Run after the detect-secrets job finishes 55 | needs: 56 | - detect-secrets 57 | 58 | .build: 59 | stage: build 60 | # No artifacts from previous stages are required 61 | dependencies: [] 62 | # Ensure a "clean" build environment 63 | variables: 64 | GIT_DEPTH: 1 65 | GIT_STRATEGY: clone 66 | # Run after detect-secrets ran successfully 67 | needs: 68 | - detect-secrets 69 | -------------------------------------------------------------------------------- /juice-shop/sonarqube/.gitlab/sonarqube.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # SPDX-License-Identifier: GPL-3.0-or-later 3 | # (c) 2020-2024 Peter Mosmans [Go Forward] 4 | # 5 | # Executes SonarScanner and uploads results to SonarQube. 6 | # 7 | # Variables: 8 | # SONAR_TOKEN SonarQube access token 9 | # SONAR_URL Location of SonarQube 10 | # TOOLS_VERSION Specifies which version of gofwd/tools-image is being used 11 | 12 | sonarqube: 13 | extends: .sast 14 | variables: 15 | GIT_DEPTH: 1 16 | GIT_STRATEGY: fetch 17 | SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" 18 | image: 19 | name: gofwd/tools-image:${TOOLS_VERSION} 20 | entrypoint: [""] 21 | cache: 22 | key: "${CI_JOB_NAME}" 23 | paths: 24 | - .sonar/cache 25 | script: 26 | - > 27 | sonar-scanner 28 | -Dsonar.exclusions=reports/** 29 | -Dsonar.host.url=${SONAR_URL} 30 | -Dsonar.path.temp=${RUNNER_TEMP_PROJECT_DIR} 31 | -Dsonar.projectKey=${CI_PROJECT_TITLE} 32 | rules: 33 | - if: "$SONAR_TOKEN != null" 34 | when: always 35 | -------------------------------------------------------------------------------- /juice-shop/trivy/.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # SPDX-License-Identifier: GPL-3.0-or-later 3 | # (c) 2020-2024 Peter Mosmans [Go Forward] 4 | 5 | # Pipeline template for automated security testing 6 | 7 | ### Variables used throughout the pipeline 8 | 9 | variables: 10 | # These variables will be used throughout the pipeline, in all jobs 11 | # Generic cache directory 12 | CACHE_DIR: /srv/cache 13 | # By default, the repository will not be used; artifacts will 14 | GIT_STRATEGY: none 15 | IMAGE_TAG: ${CI_COMMIT_SHORT_SHA} 16 | IMAGE_TAR: ${IMAGE_TAG}.tar 17 | # Tool-specific: Image versions 18 | DEPENDENCY_VERSION: 12.1.1 19 | HADOLINT_VERSION: v2.12.0-debian 20 | NJSSCAN_VERSION: 0.4.3 21 | TOOLS_VERSION: 1.8.0 22 | TRIVY_VERSION: 0.61.1 23 | 24 | ### Include several jobs 25 | 26 | include: 27 | # .pre 28 | - .gitlab/detect-secrets.gitlab-ci.yml 29 | # sast 30 | - .gitlab/hadolint.gitlab-ci.yml 31 | # sast 32 | - .gitlab/njsscan.gitlab-ci.yml 33 | # sast 34 | - .gitlab/sonarqube.gitlab-ci.yml 35 | # build 36 | - .gitlab/docker-build.gitlab-ci.yml 37 | # security 38 | - .gitlab/dependency-check.gitlab-ci.yml 39 | # security 40 | - .gitlab/dependency-track.gitlab-ci.yml 41 | # security 42 | - .gitlab/trivy.gitlab-ci.yml 43 | 44 | ### Pipeline stages 45 | 46 | stages: 47 | # Security checks over source code, can be performed parallel to building 48 | - sast 49 | # Build the artifact 50 | - build 51 | # (Dynamic) security checks using / over build artifact 52 | - security 53 | 54 | ### Jobs 55 | 56 | # All jobs that start with a dot are templates and can be extended. 57 | 58 | .sast: 59 | stage: sast 60 | # No artifacts from previous stages are required 61 | dependencies: [] 62 | # Source code is necessary 63 | variables: 64 | GIT_DEPTH: 1 65 | GIT_STRATEGY: fetch 66 | # Run after the detect-secrets job finishes 67 | needs: 68 | - detect-secrets 69 | 70 | .build: 71 | stage: build 72 | # No artifacts from previous stages are required 73 | dependencies: [] 74 | # Ensure a "clean" build environment 75 | variables: 76 | GIT_DEPTH: 1 77 | GIT_STRATEGY: clone 78 | # Run after detect-secrets ran successfully 79 | needs: 80 | - detect-secrets 81 | 82 | .security: 83 | stage: security 84 | needs: 85 | - build 86 | -------------------------------------------------------------------------------- /juice-shop/trivy/.gitlab/trivy.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # SPDX-License-Identifier: GPL-3.0-or-later 3 | # (c) 2020-2024 Peter Mosmans [Go Forward] 4 | # 5 | # Analyzes a Docker image using Trivy. 6 | # 7 | # Variables: 8 | # CACHE_DIR General cache directory 9 | # IMAGE_TAR Name of the Docker image (in tar format) 10 | # TRIVY_VERSION Specifies which version of aquasec/trivy is being used 11 | 12 | trivy: 13 | extends: .security 14 | image: 15 | name: aquasec/trivy:${TRIVY_VERSION} 16 | entrypoint: [""] 17 | before_script: 18 | - mkdir -p reports &>/dev/null || true 19 | script: 20 | - > 21 | trivy --cache-dir ${CACHE_DIR}/trivy 22 | image --input ${IMAGE_TAR} 23 | --format json 24 | --output reports/trivy-report.json 25 | --quiet 26 | --timeout 3600s ; 27 | trivy convert --format table --output reports/trivy-report.txt reports/trivy-report.json ; 28 | trivy convert --format sarif --output reports/trivy-report.sarif.json reports/trivy-report.json 29 | # Always show report 30 | after_script: 31 | - cat reports/trivy-report.txt 32 | artifacts: 33 | name: "$CI_JOB_NAME artifacts from $CI_PROJECT_NAME on $CI_COMMIT_REF_SLUG" 34 | when: always 35 | paths: 36 | - reports/trivy-report.* 37 | # Continue other tests, even if this one fails 38 | allow_failure: true 39 | -------------------------------------------------------------------------------- /juice-shop/zap/.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # SPDX-License-Identifier: GPL-3.0-or-later 3 | # (c) 2020-2024 Peter Mosmans [Go Forward] 4 | 5 | # Pipeline template for automated security testing 6 | 7 | ### Variables used throughout the pipeline 8 | 9 | variables: 10 | # These variables will be used throughout the pipeline, in all jobs 11 | # Generic cache directory 12 | CACHE_DIR: /srv/cache 13 | # By default, the repository will not be used; artifacts will 14 | GIT_STRATEGY: none 15 | IMAGE_TAG: ${CI_COMMIT_SHORT_SHA} 16 | IMAGE_TAR: ${IMAGE_TAG}.tar 17 | # Tool-specific: Image versions 18 | DEPENDENCY_VERSION: 12.1.1 19 | HADOLINT_VERSION: v2.12.0-debian 20 | NJSSCAN_VERSION: 0.4.3 21 | TOOLS_VERSION: 1.8.0 22 | TRIVY_VERSION: 0.61.1 23 | ZAP_VERSION: 2.16.1 24 | 25 | ### Include several jobs 26 | 27 | include: 28 | # .pre 29 | - .gitlab/detect-secrets.gitlab-ci.yml 30 | # sast 31 | - .gitlab/hadolint.gitlab-ci.yml 32 | # sast 33 | - .gitlab/njsscan.gitlab-ci.yml 34 | # sast 35 | - .gitlab/sonarqube.gitlab-ci.yml 36 | # build 37 | - .gitlab/docker-build.gitlab-ci.yml 38 | # security 39 | - .gitlab/dependency-check.gitlab-ci.yml 40 | # security 41 | - .gitlab/dependency-track.gitlab-ci.yml 42 | # security 43 | - .gitlab/trivy.gitlab-ci.yml 44 | # security 45 | - .gitlab/zap.gitlab-ci.yml 46 | 47 | ### Pipeline stages 48 | 49 | stages: 50 | # Security checks over source code, can be performed parallel to building 51 | - sast 52 | # Build the artifact 53 | - build 54 | # (Dynamic) security checks using / over build artifact 55 | - security 56 | 57 | ### Jobs 58 | 59 | # All jobs that start with a dot are templates and can be extended. 60 | 61 | .sast: 62 | stage: sast 63 | # No artifacts from previous stages are required 64 | dependencies: [] 65 | # Source code is necessary 66 | variables: 67 | GIT_DEPTH: 1 68 | GIT_STRATEGY: fetch 69 | # Run after the detect-secrets job finishes 70 | needs: 71 | - detect-secrets 72 | 73 | .build: 74 | stage: build 75 | # No artifacts from previous stages are required 76 | dependencies: [] 77 | # Ensure a "clean" build environment 78 | variables: 79 | GIT_DEPTH: 1 80 | GIT_STRATEGY: clone 81 | # Run after detect-secrets ran successfully 82 | needs: 83 | - detect-secrets 84 | 85 | .security: 86 | stage: security 87 | needs: 88 | - build 89 | -------------------------------------------------------------------------------- /juice-shop/zap/.gitlab/zap.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # SPDX-License-Identifier: GPL-3.0-or-later 3 | # (c) 2020-2024 Peter Mosmans [Go Forward] 4 | # 5 | # Performs a web application scan using ZAP. 6 | 7 | # Variables: 8 | # IMAGE_TAG Docker image tag 9 | # ZAP_CONFIG ZAP configuration file. 10 | # ZAP_VERSION Specifies which version of zaproxy/zaproxy is being used 11 | 12 | zap: 13 | extends: .security 14 | variables: 15 | GIT_DEPTH: 1 16 | GIT_STRATEGY: fetch 17 | ZAP_CONFIG: zap.yaml 18 | image: 19 | name: zaproxy/zap-bare:${ZAP_VERSION} 20 | entrypoint: [""] 21 | services: 22 | - name: $IMAGE_TAG 23 | alias: juice-shop 24 | before_script: 25 | - mkdir -p reports &>/dev/null || true 26 | # Use absolute report paths in the configuration file 27 | - > 28 | REPLACE=$(sed -e 's/[&\\/]/\\&/g; s/$/\\/' -e '$s/\\$//' <<<"$CI_PROJECT_DIR") ; 29 | sed -i "s/CI_PROJECT_DIR/$REPLACE/g" ${ZAP_CONFIG} 30 | # Check if the service is up 31 | - > 32 | curl --max-time 120 33 | --retry 60 34 | --retry-connrefused 35 | --retry-delay 5 36 | --fail 37 | --ipv4 38 | --silent http://$(getent ahostsv4 juice-shop|tail -1|awk '{print $1}'):3000 >/dev/null || exit 1 39 | script: 40 | - zap.sh -cmd -notel -silent -autorun ${CI_PROJECT_DIR}/${ZAP_CONFIG} 41 | # Set exit code based on whether there were warnings or errors 42 | - > 43 | warning=$(awk -F '[{}:,"]' '{print $9}' reports/zap-report.json) ; 44 | fail=$(awk -F '[{}:,"]' '{print $13}' reports/zap-report.json) ; 45 | if (($warning>0)) || (($fail>0)); then 46 | exit 1; 47 | fi 48 | # Always show report 49 | after_script: 50 | - cat reports/zap-report.md 51 | artifacts: 52 | name: "$CI_JOB_NAME artifacts from $CI_PROJECT_NAME on $CI_COMMIT_REF_SLUG" 53 | when: always 54 | paths: 55 | - reports/zap-*.* 56 | # Only flag the job as failed, not the whole pipeline 57 | allow_failure: true 58 | -------------------------------------------------------------------------------- /juice-shop/zap/zap.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | env: 3 | contexts: 4 | - excludePaths: [] 5 | name: baseline 6 | urls: 7 | - http://juice-shop:3000/ 8 | parameters: 9 | failOnError: true 10 | failOnWarning: true 11 | progressToStdout: false 12 | jobs: 13 | - parameters: 14 | enableTags: false 15 | maxAlertsPerRule: 10 16 | type: passiveScan-config 17 | - parameters: 18 | maxDuration: 5 19 | url: http://juice-shop:3000/ 20 | type: spider 21 | - parameters: 22 | maxDuration: 5 23 | type: passiveScan-wait 24 | - parameters: 25 | format: Long 26 | summaryFile: CI_PROJECT_DIR/reports/zap-report.json 27 | rules: [] 28 | type: outputSummary 29 | - parameters: 30 | reportDescription: "" 31 | reportDir: CI_PROJECT_DIR/reports 32 | reportFile: zap-report.html 33 | reportTitle: ZAP Scanning Report 34 | template: traditional-html 35 | type: report 36 | - parameters: 37 | reportDescription: "" 38 | reportDir: CI_PROJECT_DIR/reports 39 | reportFile: zap-report.md 40 | reportTitle: ZAP Scanning Report 41 | template: traditional-md 42 | type: report 43 | - parameters: 44 | reportDescription: "" 45 | reportDir: CI_PROJECT_DIR/reports 46 | reportFile: zap-report.sarif.json 47 | reportTitle: ZAP Scanning Report 48 | template: sarif-json 49 | type: report 50 | -------------------------------------------------------------------------------- /register-runners.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (C) 2023-2024 Peter Mosmans [Go Forward] 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | # 5 | # Register GitLab runners with a runner (group) token 6 | # Part of https://github.com/PeterMosmans/gitlab-demolab 7 | 8 | # Usage: register-runners.sh TOKEN 9 | 10 | # shellcheck disable=SC1091 11 | source .env 12 | # Ensure that all variables are defined 13 | set -u 14 | token=$1 15 | 16 | # Note that the hard-coded service name gitlab is being used 17 | for runner in $(docker-compose ps | awk '/-runner/{print $1}'); do 18 | echo "Trying to register runner $runner" 19 | docker exec -it "$runner" /bin/bash -c "/usr/bin/gitlab-runner register \ 20 | --non-interactive \ 21 | --url http://gitlab:${GITLAB_PORT} \ 22 | --clone-url http://gitlab:${GITLAB_PORT} \ 23 | --description $runner \ 24 | --docker-image docker:${DIND_VERSION} \ 25 | --docker-network-mode ${DEMO_NAME}-network \ 26 | --docker-privileged \ 27 | --docker-pull-policy if-not-present \ 28 | --docker-volumes /var/run/docker.sock:/var/run/docker.sock \ 29 | --docker-volumes ${DEMO_NAME}-runner_cache:/srv/cache:z \ 30 | --env "DOCKER_DRIVER=overlay2" \ 31 | --executor docker \ 32 | --non-interactive \ 33 | --token ${token}" 34 | done 35 | -------------------------------------------------------------------------------- /update_checker.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright (C) 2022-2024 Peter Mosmans [Go Forward] 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | # Helper script to check whether new versions of Docker images are available. 6 | # Part of https://github.com/PeterMosmans/gitlab-demolab 7 | 8 | # shellcheck disable=SC2034 9 | 10 | set +e 11 | 12 | COL_BOLD="\033[1m" 13 | COL_GREEN="\033[32m" 14 | COL_RED="\033[0;31m" 15 | COL_RESET="\033[0m" 16 | COL_YELLOW="\033[0;33m" 17 | 18 | temp_file=$(mktemp) 19 | 20 | # Clean up temporary file when exiting 21 | trap 'rm -f $temp_file' EXIT 22 | 23 | # Determine latest tag and set the GLOBAL variable latest 24 | show_latest_tags() { 25 | repository=$1 26 | image=$2 27 | suffix=$3 28 | latest="" 29 | echo -e "Showing results for: ${COL_BOLD}$repository/$image${COL_RESET}" 30 | if [[ $suffix != nosuffix ]]; then 31 | local expander="&name=$suffix" 32 | else 33 | local expander="" 34 | fi 35 | curl --silent -L "https://registry.hub.docker.com/v2/repositories/$repository/$image/tags?page_size=100$expander" | jq --raw-output '.results[].name' | (grep -Ev '(beta|latest|nightly|rc|snapshot)' || true) | grep -P '^v?\d+\.\d+\.\d+' | sort -rV > "$temp_file" 36 | if [[ -n $suffix ]]; then 37 | if [[ $suffix == nosuffix ]]; then 38 | latest=$(grep -P '^v?\d+\.\d+\.\d+$' "$temp_file" | head -1) 39 | else 40 | latest=$(grep "$suffix$" "$temp_file" | head -1) 41 | fi 42 | else 43 | latest=$(head -1 "$temp_file") 44 | fi 45 | } 46 | 47 | # Display version number from an environment file 48 | check_env() { 49 | in_use=$(awk -F '=' "/$1_VERSION/{print \$2}" .env) 50 | if [ -n "$latest" ] && [ -n "$in_use" ]; then 51 | if [ "$latest" = "$in_use" ]; then 52 | echo -e "${COL_BOLD}.env${COL_RESET}: $COL_GREEN$in_use$COL_RESET is the latest version" 53 | else 54 | echo -e "${COL_BOLD}.env${COL_RESET}: $COL_RED$in_use$COL_RESET can be updated to $COL_BOLD$latest$COL_RESET" 55 | fi 56 | fi 57 | } 58 | 59 | # Display version number from a YAML file 60 | check_tool() { 61 | config=$2 62 | if [ -z "$config" ]; then 63 | config=".gitlab.ci.yml" 64 | fi 65 | in_use=$(awk -F ': ' "/$1_VERSION/{print \$2}" "$config") 66 | if [ -n "$in_use" ]; then 67 | if [ "$latest" = "$in_use" ]; then 68 | echo -e "${COL_BOLD}$config${COL_RESET}: $COL_GREEN$in_use$COL_RESET is the latest version" 69 | else 70 | echo -e "${COL_BOLD}$config${COL_RESET}: $COL_RED$in_use$COL_RESET will be updated to $COL_BOLD$latest$COL_RESET" 71 | echo "Don't forget to test whether this version still works..." 72 | sed --in-place --expression "s/${in_use}/${latest}/" "${config}" 73 | fi 74 | fi 75 | } 76 | 77 | # Check for all defined images in the .env file 78 | check_lab() { 79 | if [ -f ".env" ]; then 80 | show_latest_tags library docker dind 81 | check_env DIND 82 | show_latest_tags dependencytrack apiserver 83 | check_env DTRACK_API 84 | show_latest_tags dependencytrack frontend 85 | check_env DTRACK_FRONTEND 86 | show_latest_tags gitlab gitlab-ce 87 | check_env GITLAB 88 | show_latest_tags library sonarqube community 89 | check_env SONARQUBE 90 | fi 91 | } 92 | 93 | # Check for all defined images in the .gitlab-ci.yml file 94 | check_pipelines() { 95 | show_latest_tags gofwd tools-image 96 | check_configs TOOL 97 | show_latest_tags owasp dependency-check 98 | check_configs DEPENDENCY 99 | show_latest_tags wagoodman dive nosuffix 100 | check_configs DIVE 101 | show_latest_tags goodwithtech dockle nosuffix 102 | check_configs DOCKLE 103 | show_latest_tags hadolint hadolint debian 104 | check_configs HADOLINT 105 | show_latest_tags aquasec trivy nosuffix 106 | check_configs TRIVY 107 | show_latest_tags opensecurity njsscan 108 | check_configs NJSSCAN 109 | show_latest_tags zaproxy zap-bare 110 | check_configs ZAP 111 | } 112 | 113 | check_configs() { 114 | # shellcheck disable=SC2044 115 | for conf in $(find . -type f -name '.gitlab-ci.yml'); do 116 | check_tool "$1" "$conf" 117 | done 118 | } 119 | 120 | # If command line parameters are used, try to find latest version 121 | if [ $# -eq 1 ]; then 122 | echo -e "Usage: ${COL_BOLD}update_checker.sh${COL_RESET}" 123 | echo -e " Determines whether latest image versions are in use\n" 124 | echo -e " ${COL_BOLD}update_checker.sh${COL_RESET} REPOSITORY IMAGE" 125 | echo -e " Displays latest image version of REPOSITORY/IMAGE on Docker Hub\n" 126 | exit 0 127 | fi 128 | if [ $# -eq 2 ]; then 129 | show_latest_tags "$1" "$2" 130 | echo "$latest" 131 | echo -e "\nLast 10 tags:" 132 | head -10 "$temp_file" 133 | else 134 | check_lab 135 | check_pipelines 136 | fi 137 | --------------------------------------------------------------------------------