├── .gitignore ├── LICENSE ├── README.md ├── csf_client ├── .dockerignore ├── .gitignore ├── Dockerfile ├── LICENSE ├── functions_lib.sh ├── helper_lib.sh ├── output_lib.sh ├── run-bash.sh └── tests │ ├── 1_host_configuration.sh │ ├── 2_docker_daemon_configuration.sh │ ├── 3_docker_daemon_configuration_files.sh │ ├── 4_container_images.sh │ ├── 5_container_runtime.sh │ ├── 6_docker_security_operations.sh │ ├── 7_docker_swarm_configuration.sh │ └── 99_community_checks.sh └── csf_server ├── .dockerignore ├── .gitignore ├── Dockerfile ├── LICENSE ├── csf_server ├── __init__.py ├── settings.py ├── urls.py └── wsgi.py ├── csfapi ├── __init__.py ├── admin.py ├── apps.py ├── models.py ├── serializers.py ├── tests.py ├── urls.py └── views.py ├── manage.py ├── requirements.txt ├── start.sh ├── static ├── chartist.min.css ├── chartist.min.js ├── checks.json ├── jquery.min.js └── style.css └── templates ├── bottom.html ├── footer.html ├── header.html ├── navigation.html ├── screens ├── add-clientgroup.html ├── dashboard.html ├── screen-template.html ├── update-client.html ├── update-clientgroup.html ├── update-issue.html ├── view-all-issues.html ├── view-clientgroup.html ├── view-clients.html ├── view-issue.html ├── view-issues-client.html └── view-issues-clientgroup.html ├── static-head.html └── top.html /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | ENV/ 90 | env.bak/ 91 | venv.bak/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | 106 | #csf_client 107 | csf_client/logs/ 108 | csf_client/.idea/ 109 | 110 | #CSF_Server 111 | #Django 112 | */migrations/* 113 | csf_server/db/* -------------------------------------------------------------------------------- /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 | # ArmourBird CSF - Container Security Framework 2 | [![Follow ArmourBird on Twitter](https://img.shields.io/twitter/follow/armourbird.svg?style=social&label=Follow%20%40armourbird)](https://twitter.com/intent/user?screen_name=armourbird "Follow ArmourBird on Twitter") [![BlackHat USA Arsenal 2019](https://github.com/r3ver53r/staticfiles/blob/master/images/bh-usa-2019.svg)](https://www.blackhat.com/us-19/arsenal/schedule/index.html#csf-container-security-framework-17001) 3 | 4 | 5 | **Note:** The CSF Client is under active development and is getting converted into GoLang for better performace and architecture 6 | 7 | 8 | ## Table of Contents 9 | 10 | 1. [About](#about) 11 | 2. [Architecture Diagram](#architecture-diagram) 12 | 3. [APIs-CSF Server](#apis-csf-server) 13 | 4. [Installation/Usage](#installationusage) 14 | 5. [Building Docker Images](#building-docker-images) 15 | 6. [Sneak Peak](#sneak-peak) 16 | 7. [To Do](#to-do) 17 | 8. [Website](#website) 18 | 9. [Twitter](#twitter) 19 | 10. [References](#references) 20 | 21 | 22 | ## About 23 | 24 | **ArmourBird CSF - Container Security Framework** is an extensible, modular, API-first framework build for regular security monitoring of docker installations and containers against CIS and other custom security checks. 25 | 26 | ArmourBird CSF has a client-server architecture and is thus divided into two components: 27 | 28 | a) **CSF Client** 29 | 30 | - This component is responsible for monitoring the docker installations, containers, and images on target machines 31 | - In the initial release, it will be checking against Docker CIS benchmark 32 | - The checks in the CSF client will be configurable and thus will be expanded in future releases and updates 33 | - It has been build on top of Docker bench for security 34 | 35 | b) **CSF Server** 36 | 37 | - This will be the receiver agent for the security logs generated by the various distributed CSF clients (installed on multiple physical/virtual machines) 38 | - This will also have a UI sub-component for unified management and dashboard-ing of the various vulnerabilities/issues logged by the CSF Clients 39 | - This server will also expose APIs that can be used for integrating with other systems 40 | 41 | **Important Note**: The tool is currently in beta mode. Hence the debug flag of django (CSF Server) is enabled and the SQLite is used as DB in the same docker container. Hence, spinning up a new docker container will reset the database. 42 | 43 | ## Architecture Diagram 44 | ![ ArmourBird CSF Architecture Diagram](https://github.com/r3ver53r/staticfiles/blob/master/images/csf_arch.jpeg) 45 | 46 | ## APIs CSF Server 47 | 48 | **Issue APIs** 49 | 50 | POST /issues 51 | - For reporting issues from CSF clients 52 | 53 | GET /issues/{issueId} 54 | - For listing specific issue with {id} 55 | 56 | GET /issues 57 | - For listing all issues reported by all CSF clients 58 | 59 | PUT /issues/{issueId} 60 | - For updating a specific issue (like for severity, comments, etc.) 61 | 62 | DELETE /issues/{issueId} 63 | - For deleting specific issue 64 | 65 | **Client APIs** 66 | 67 | POST /clients 68 | - For adding a CSF client 69 | 70 | GET /clients/{clientId} 71 | - For listing specific CSF client 72 | 73 | GET /clients/ 74 | - For listing all the CSF clients 75 | 76 | PUT /clients/{clientId} 77 | - For updating the CSF client (for e.g. IP addr, etc.) 78 | 79 | DELETE /clients/{clientId} 80 | - For deleting a CSF client from the network 81 | 82 | **Client Group APIs** 83 | 84 | POST /clientGroup 85 | - Adding client to a specific group (for e.g. product1, HRNetwork, product2, etc.) 86 | 87 | GET /clientGroup/{groupID} 88 | - For listing client group details 89 | 90 | GET /clientGroup/ 91 | - For listing all client groups 92 | 93 | PUT /clientGroup/{groupID} 94 | - For updating client group 95 | 96 | DELETE /clientGroup/{groupId} 97 | - For deleting client group 98 | 99 | ## Installation/Usage 100 | 101 | **CSF client** run as a docker container on the compute instances running docker installation. It can be executed using the following command using the docker image hosted on hub.docker.com: 102 | 103 | ``` 104 | docker run -it --net host --pid host --userns host --cap-add audit_control \ 105 | -e DOCKER_CONTENT_TRUST=$DOCKER_CONTENT_TRUST \ 106 | -e CSF_CDN='' \ 107 | -v /etc:/etc \ 108 | -v /usr/bin/docker-containerd:/usr/bin/docker-containerd \ 109 | -v /usr/bin/docker-runc:/usr/bin/docker-runc \ 110 | -v /usr/lib/systemd:/usr/lib/systemd \ 111 | -v /var/lib:/var/lib \ 112 | -v /var/run/docker.sock:/var/run/docker.sock \ 113 | --label csf_client \ 114 | -d armourbird/csf_client 115 | ``` 116 | Make sure to update CSF_CDN environment variable in the above command with the CSF server URL. Once the container is executed, it will start sending issue logs to the CSF server on constant intervals. 117 | 118 | **CSF server** can run as a docker container or natively on a web server on which various CSF clients will be sending data. You can run it on your server using the following command using the docker image hosted on hub.docker.com 119 | 120 | ``` 121 | docker run -p 80:8000 -d armourbird/csf_server 122 | ``` 123 | 124 | Browse the CSF server via the following links 125 | 126 | - Dashboard: http://< your-domain >/dashboard/ 127 | - APIs: http://< your-domain >/api/ 128 | 129 | 130 | 131 | ## Building Docker Images 132 | Building docker image for CSF Client 133 | ``` 134 | git clone git@github.com:armourbird/csf.git 135 | cd csf_client 136 | docker build . -t csf_client 137 | ``` 138 | Building docker image for CSF Server 139 | ``` 140 | git clone git@github.com:armourbird/csf.git 141 | cd csf_server 142 | docker build . -t csf_server 143 | ``` 144 | 145 | ## Sneak Peak 146 | **Dashboard** 147 | 148 | 149 | **API View** 150 | 151 | 152 | ## To Do 153 | - [ ] Integrate non-development web server and database 154 | - [ ] Add API key support to CSF Server 155 | - [ ] Add further checks in CSF Client 156 | - [ ] Add create/update/delete functionality for Client Groups 157 | - [ ] Add update/delete functionality for Clients 158 | - [ ] Improve dashboard UI 159 | 160 | ## Website 161 | https://www.armourbird.com/ 162 | 163 | ## Twitter 164 | [http://twitter.com/ArmourBird](http://twitter.com/ArmourBird) 165 | 166 | ## References 167 | [https://www.cisecurity.org/cis-benchmarks](https://www.cisecurity.org/cis-benchmarks) 168 | [https://github.com/docker/docker-bench-security](https://github.com/docker/docker-bench-security) 169 | -------------------------------------------------------------------------------- /csf_client/.dockerignore: -------------------------------------------------------------------------------- 1 | .gitignore 2 | sample.json -------------------------------------------------------------------------------- /csf_client/.gitignore: -------------------------------------------------------------------------------- 1 | logs/ 2 | .idea/ -------------------------------------------------------------------------------- /csf_client/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.10 2 | 3 | LABEL \ 4 | name="csf-client" \ 5 | version="1.0Beta" \ 6 | github="https://github.com/armourbird/csf" 7 | 8 | RUN \ 9 | sed -i 's/http\:\/\/dl-cdn.alpinelinux.org/https\:\/\/alpine.global.ssl.fastly.net/g' /etc/apk/repositories && \ 10 | apk add --no-cache \ 11 | iproute2 \ 12 | docker \ 13 | curl \ 14 | ca-certificates \ 15 | dumb-init && \ 16 | rm -rf /usr/bin/docker?* 17 | 18 | COPY ./*.sh /usr/local/bin/ 19 | COPY ./tests/*.sh /usr/local/bin/tests/ 20 | 21 | HEALTHCHECK CMD exit 0 22 | 23 | WORKDIR /usr/local/bin 24 | 25 | ENTRYPOINT [ "/usr/bin/dumb-init", "run-bash.sh" ] 26 | CMD [""] 27 | -------------------------------------------------------------------------------- /csf_client/functions_lib.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | host_configuration() { 4 | check_1 5 | check_1_1 6 | check_1_2 7 | check_1_3 8 | check_1_4 9 | check_1_5 10 | check_1_6 11 | check_1_7 12 | check_1_8 13 | check_1_9 14 | check_1_10 15 | check_1_11 16 | check_1_12 17 | check_1_13 18 | check_1_end 19 | } 20 | 21 | docker_daemon_configuration() { 22 | check_2 23 | check_2_1 24 | check_2_2 25 | check_2_3 26 | check_2_4 27 | check_2_5 28 | check_2_6 29 | check_2_7 30 | check_2_8 31 | check_2_9 32 | check_2_10 33 | check_2_11 34 | check_2_12 35 | check_2_13 36 | check_2_14 37 | check_2_15 38 | check_2_16 39 | check_2_17 40 | check_2_18 41 | check_2_end 42 | } 43 | 44 | docker_daemon_files() { 45 | check_3 46 | check_3_1 47 | check_3_2 48 | check_3_3 49 | check_3_4 50 | check_3_5 51 | check_3_6 52 | check_3_7 53 | check_3_8 54 | check_3_9 55 | check_3_10 56 | check_3_11 57 | check_3_12 58 | check_3_13 59 | check_3_14 60 | check_3_15 61 | check_3_16 62 | check_3_17 63 | check_3_18 64 | check_3_19 65 | check_3_20 66 | check_3_end 67 | } 68 | 69 | container_images() { 70 | check_4 71 | check_4_1 72 | check_4_2 73 | check_4_3 74 | check_4_4 75 | check_4_5 76 | check_4_6 77 | check_4_7 78 | check_4_8 79 | check_4_9 80 | check_4_10 81 | check_4_11 82 | check_4_end 83 | } 84 | 85 | container_runtime() { 86 | check_5 87 | check_running_containers 88 | check_5_1 89 | check_5_2 90 | check_5_3 91 | check_5_4 92 | check_5_5 93 | check_5_6 94 | check_5_7 95 | check_5_8 96 | check_5_9 97 | check_5_10 98 | check_5_11 99 | check_5_12 100 | check_5_13 101 | check_5_14 102 | check_5_15 103 | check_5_16 104 | check_5_17 105 | check_5_18 106 | check_5_19 107 | check_5_20 108 | check_5_21 109 | check_5_22 110 | check_5_23 111 | check_5_24 112 | check_5_25 113 | check_5_26 114 | check_5_27 115 | check_5_28 116 | check_5_29 117 | check_5_30 118 | check_5_31 119 | check_5_end 120 | } 121 | 122 | docker_security_operations() { 123 | check_6 124 | check_6_1 125 | check_6_2 126 | check_6_end 127 | } 128 | 129 | docker_swarm_configuration() { 130 | check_7 131 | check_7_1 132 | check_7_2 133 | check_7_3 134 | check_7_4 135 | check_7_5 136 | check_7_6 137 | check_7_7 138 | check_7_8 139 | check_7_9 140 | check_7_10 141 | check_7_end 142 | } 143 | 144 | community_checks() { 145 | check_c 146 | check_c_1 147 | check_c_end 148 | } 149 | 150 | # CIS 151 | cis() { 152 | host_configuration 153 | docker_daemon_configuration 154 | docker_daemon_files 155 | container_images 156 | container_runtime 157 | docker_security_operations 158 | docker_swarm_configuration 159 | } 160 | 161 | # Community contributed 162 | community() { 163 | community_checks 164 | } 165 | 166 | # All 167 | all() { 168 | cis 169 | community 170 | } 171 | -------------------------------------------------------------------------------- /csf_client/helper_lib.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Returns the absolute path of a given string 4 | abspath () { case "$1" in /*)printf "%s\n" "$1";; *)printf "%s\n" "$PWD/$1";; esac; } 5 | 6 | # Audit rules default path 7 | auditrules="/etc/audit/audit.rules" 8 | 9 | # Compares versions of software of the format X.Y.Z 10 | do_version_check() { 11 | [ "$1" = "$2" ] && return 10 12 | 13 | ver1front=$(printf "%s" "$1" | cut -d "." -f -1) 14 | ver1back=$(printf "%s" "$1" | cut -d "." -f 2-) 15 | ver2front=$(printf "%s" "$2" | cut -d "." -f -1) 16 | ver2back=$(printf "%s" "$2" | cut -d "." -f 2-) 17 | 18 | if [ "$ver1front" != "$1" ] || [ "$ver2front" != "$2" ]; then 19 | [ "$ver1front" -gt "$ver2front" ] && return 11 20 | [ "$ver1front" -lt "$ver2front" ] && return 9 21 | 22 | [ "$ver1front" = "$1" ] || [ -z "$ver1back" ] && ver1back=0 23 | [ "$ver2front" = "$2" ] || [ -z "$ver2back" ] && ver2back=0 24 | do_version_check "$ver1back" "$ver2back" 25 | return $? 26 | else 27 | [ "$1" -gt "$2" ] && return 11 || return 9 28 | fi 29 | } 30 | 31 | # Extracts commandline args from the newest running processes named like the first parameter 32 | get_command_line_args() { 33 | PROC="$1" 34 | 35 | for PID in $(pgrep -f -n "$PROC"); do 36 | tr "\0" " " < /proc/"$PID"/cmdline 37 | done 38 | } 39 | 40 | # Extract the cumulative command line arguments for the docker daemon 41 | # 42 | # If specified multiple times, all matches are returned. 43 | # Accounts for long and short variants, call with short option. 44 | # Does not account for option defaults or implicit options. 45 | get_docker_cumulative_command_line_args() { 46 | OPTION="$1" 47 | 48 | if ! get_command_line_args "docker daemon" >/dev/null 2>&1 ; then 49 | line_arg="docker daemon" 50 | else 51 | line_arg="dockerd" 52 | fi 53 | 54 | get_command_line_args "$line_arg" | 55 | # normalize known long options to their short versions 56 | sed \ 57 | -e 's/\-\-debug/-D/g' \ 58 | -e 's/\-\-host/-H/g' \ 59 | -e 's/\-\-log-level/-l/g' \ 60 | -e 's/\-\-version/-v/g' \ 61 | | 62 | # normalize parameters separated by space(s) to -O=VALUE 63 | sed \ 64 | -e 's/\-\([DHlv]\)[= ]\([^- ][^ ]\)/-\1=\2/g' \ 65 | | 66 | # get the last interesting option 67 | tr ' ' "\n" | 68 | grep "^${OPTION}" | 69 | # normalize quoting of values 70 | sed \ 71 | -e 's/"//g' \ 72 | -e "s/'//g" 73 | } 74 | 75 | # Extract the effective command line arguments for the docker daemon 76 | # 77 | # Accounts for multiple specifications, takes the last option. 78 | # Accounts for long and short variants, call with short option 79 | # Does not account for option default or implicit options. 80 | get_docker_effective_command_line_args() { 81 | OPTION="$1" 82 | get_docker_cumulative_command_line_args "$OPTION" | tail -n1 83 | } 84 | 85 | get_docker_configuration_file_args() { 86 | OPTION="$1" 87 | FILE="$(get_docker_effective_command_line_args '--config-file' | \ 88 | sed 's/.*=//g')" 89 | 90 | if [ -f "$FILE" ]; then 91 | CONFIG_FILE="$FILE" 92 | elif [ -f '/etc/docker/daemon.json' ]; then 93 | CONFIG_FILE='/etc/docker/daemon.json' 94 | else 95 | CONFIG_FILE='/dev/null' 96 | fi 97 | 98 | grep "$OPTION" "$CONFIG_FILE" | sed 's/.*: //g' | tr -d \", 99 | } 100 | 101 | get_systemd_service_file() { 102 | SERVICE="$1" 103 | 104 | if [ -f "/etc/systemd/system/$SERVICE" ]; then 105 | echo "/etc/systemd/system/$SERVICE" 106 | elif systemctl show -p FragmentPath "$SERVICE" 2> /dev/null 1>&2; then 107 | systemctl show -p FragmentPath "$SERVICE" | sed 's/.*=//' 108 | else 109 | echo "/usr/lib/systemd/system/$SERVICE" 110 | fi 111 | } 112 | 113 | yell_info() { 114 | yell "# ------------------------------------------------------------------------------ 115 | # Docker Bench for Security v$version 116 | # 117 | # Docker, Inc. (c) 2015- 118 | # 119 | # Checks for dozens of common best-practices around deploying Docker containers in production. 120 | # Inspired by the CIS Docker Community Edition Benchmark v1.1.0. 121 | # ------------------------------------------------------------------------------" 122 | } 123 | -------------------------------------------------------------------------------- /csf_client/output_lib.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | API_KEY='abc123' 3 | 4 | if ! [ -z "$nocolor" ] && [ "$nocolor" = "nocolor" ]; then 5 | bldred='' 6 | bldgrn='' 7 | bldblu='' 8 | bldylw='' 9 | txtrst='' 10 | else 11 | bldred='\033[1;31m' 12 | bldgrn='\033[1;32m' 13 | bldblu='\033[1;34m' 14 | bldylw='\033[1;33m' # Yellow 15 | txtrst='\033[0m' 16 | fi 17 | 18 | logit () { 19 | printf "%b\n" "$1" | tee -a "$logger" 20 | } 21 | 22 | info () { 23 | printf "%b\n" "${bldblu}[INFO]${txtrst} $1" | tee -a "$logger" 24 | } 25 | 26 | pass () { 27 | printf "%b\n" "${bldgrn}[PASS]${txtrst} $1" | tee -a "$logger" 28 | } 29 | 30 | warn () { 31 | printf "%b\n" "${bldred}[WARN]${txtrst} $1" | tee -a "$logger" 32 | } 33 | 34 | note () { 35 | printf "%b\n" "${bldylw}[NOTE]${txtrst} $1" | tee -a "$logger" 36 | } 37 | 38 | yell () { 39 | printf "%b\n" "${bldylw}$1${txtrst}\n" 40 | } 41 | 42 | beginjson () { 43 | printf "{\n \"dockerbenchsecurity\": \"%s\",\n \"start\": %s,\n \"tests\": [" "$1" "$2" | tee "$logger.json" 2>/dev/null 1>&2 44 | } 45 | 46 | endjson (){ 47 | printf "\n ], \"checks\": %s, \"score\": %s, \"end\": %s \n}\n" "$1" "$2" "$3" | tee -a "$logger.json" 2>/dev/null 1>&2 48 | } 49 | 50 | logjson (){ 51 | printf "\n \"%s\": \"%s\"," "$1" "$2" | tee -a "$logger.json" 2>/dev/null 1>&2 52 | } 53 | 54 | SSEP= 55 | SEP= 56 | startsectionjson() { 57 | printf "%s\n {\"id\": \"%s\", \"desc\": \"%s\", \"results\": [" "$SSEP" "$1" "$2" | tee -a "$logger.json" 2>/dev/null 1>&2 58 | SEP= 59 | SSEP="," 60 | } 61 | 62 | endsectionjson() { 63 | printf "\n ]}" | tee -a "$logger.json" 2>/dev/null 1>&2 64 | } 65 | 66 | starttestjson() { 67 | printf "%s\n {\"id\": \"%s\", \"desc\": \"%s\", " "$SEP" "$1" "$2" | tee -a "$logger.json" 2>/dev/null 1>&2 68 | SEP="," 69 | } 70 | 71 | resulttestjson() { 72 | if [ $# -eq 1 ]; then 73 | printf "\"result\": \"%s\"}" "$1" | tee -a "$logger.json" 2>/dev/null 1>&2 74 | elif [ $# -eq 2 ]; then 75 | # Result also contains details 76 | printf "\"result\": \"%s\", \"details\": \"%s\"}" "$1" "$2" | tee -a "$logger.json" 2>/dev/null 1>&2 77 | else 78 | # Result also includes details and a list of items. Add that directly to details and to an array property "items" 79 | itemsJson=$(printf "["; ISEP=""; for item in $3; do printf "%s\"%s\"" "$ISEP" "$item"; ISEP=","; done; printf "]") 80 | printf "\"result\": \"%s\", \"details\": \"%s: %s\", \"items\": %s}" "$1" "$2" "$3" "$itemsJson" | tee -a "$logger.json" 2>/dev/null 1>&2 81 | fi 82 | } 83 | -------------------------------------------------------------------------------- /csf_client/run-bash.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | while true 4 | do 5 | #Output log file details 6 | mkdir -p logs 7 | dt=`date '+%d-%m-%Y_%H-%M-%S'` 8 | logger='logs/output_'$dt'.log' 9 | 10 | #Load all tests. It will not execute the tests as they are inside the functions 11 | for test in tests/*.sh; do 12 | . ./"$test" 13 | done 14 | 15 | #Load all tests functions from this script 16 | . ./functions_lib.sh 17 | 18 | #Load all dependency functions for outputing data 19 | . ./output_lib.sh 20 | 21 | #Dependency functions from helper_lib.sh 22 | . ./helper_lib.sh 23 | 24 | #Executing all tests under cis() within functions_lib.sh 25 | printf '{"tests":[' | tee -a "$logger.json" 2>/dev/null 1>&2 26 | cis 27 | printf "]}" | tee -a "$logger.json" 2>/dev/null 1>&2 28 | 29 | #Sending data to CDN. Need to set CSF_CDN and CSF_API_KEY env variables 30 | #export ENV_VAR=value 31 | cdn=$CSF_CDN 32 | api_key=$CSF_API_KEY 33 | cdn_url=$cdn 34 | base64_logfile=`base64 $logger.json` 35 | base64_logfile=$(echo $base64_logfile|tr -d '\n' | tr -d ' ') 36 | curl --request POST $cdn_url --data "data=$base64_logfile" 37 | echo 38 | echo "JSON log posted on CDN" 39 | time_unit=m 40 | sleep_time=$CSF_INTERVAL 41 | echo "Sleeping for: $sleep_time$time_unit" 42 | sleep $sleep_time$time_unit 43 | done 44 | -------------------------------------------------------------------------------- /csf_client/tests/1_host_configuration.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | check_1() { 4 | logit "" 5 | id_1="1" 6 | desc_1="Host Configuration" 7 | check_1="$id_1 - $desc_1" 8 | info "$check_1" 9 | startsectionjson "$id_1" "$desc_1" 10 | } 11 | 12 | # 1.1 13 | check_1_1() { 14 | id_1_1="1.1" 15 | desc_1_1="Ensure a separate partition for containers has been created" 16 | check_1_1="$id_1_1 - $desc_1_1" 17 | starttestjson "$id_1_1" "$desc_1_1" 18 | 19 | totalChecks=$((totalChecks + 1)) 20 | 21 | if mountpoint -q -- "$(docker info -f '{{ .DockerRootDir }}')" >/dev/null 2>&1; then 22 | pass "$check_1_1" 23 | resulttestjson "PASS" 24 | currentScore=$((currentScore + 1)) 25 | else 26 | warn "$check_1_1" 27 | resulttestjson "WARN" 28 | currentScore=$((currentScore - 1)) 29 | fi 30 | } 31 | 32 | # 1.2 33 | check_1_2() { 34 | id_1_2="1.2" 35 | desc_1_2="Ensure the container host has been Hardened" 36 | check_1_2="$id_1_2 - $desc_1_2" 37 | starttestjson "$id_1_2" "$desc_1_2" 38 | 39 | totalChecks=$((totalChecks + 1)) 40 | note "$check_1_2" 41 | resulttestjson "INFO" 42 | currentScore=$((currentScore + 0)) 43 | } 44 | 45 | # 1.3 46 | check_1_3() { 47 | id_1_3="1.3" 48 | desc_1_3="Ensure Docker is up to date" 49 | check_1_3="$id_1_3 - $desc_1_3" 50 | starttestjson "$id_1_3" "$desc_1_3" 51 | 52 | totalChecks=$((totalChecks + 1)) 53 | docker_version=$(docker version | grep -i -A2 '^server' | grep ' Version:' \ 54 | | awk '{print $NF; exit}' | tr -d '[:alpha:]-,') 55 | docker_current_version="$(date +%y.%m.0 -d @$(( $(date +%s) - 2592000)))" 56 | do_version_check "$docker_current_version" "$docker_version" 57 | if [ $? -eq 11 ]; then 58 | info "$check_1_3" 59 | info " * Using $docker_version, verify is it up to date as deemed necessary" 60 | info " * Your operating system vendor may provide support and security maintenance for Docker" 61 | resulttestjson "INFO" "Using $docker_version" 62 | currentScore=$((currentScore + 0)) 63 | else 64 | pass "$check_1_3" 65 | info " * Using $docker_version which is current" 66 | info " * Check with your operating system vendor for support and security maintenance for Docker" 67 | resulttestjson "PASS" "Using $docker_version" 68 | currentScore=$((currentScore + 0)) 69 | fi 70 | } 71 | 72 | # 1.4 73 | check_1_4() { 74 | id_1_4="1.4" 75 | desc_1_4="Ensure only trusted users are allowed to control Docker daemon" 76 | check_1_4="$id_1_4 - $desc_1_4" 77 | starttestjson "$id_1_4" "$desc_1_4" 78 | 79 | totalChecks=$((totalChecks + 1)) 80 | docker_users=$(getent group docker) 81 | info "$check_1_4" 82 | for u in $docker_users; do 83 | info " * $u" 84 | done 85 | resulttestjson "INFO" "users" "$docker_users" 86 | currentScore=$((currentScore + 0)) 87 | } 88 | 89 | # 1.5 90 | check_1_5() { 91 | id_1_5="1.5" 92 | desc_1_5="Ensure auditing is configured for the Docker daemon" 93 | check_1_5="$id_1_5 - $desc_1_5" 94 | starttestjson "$id_1_5" "$desc_1_5" 95 | 96 | totalChecks=$((totalChecks + 1)) 97 | file="/usr/bin/docker " 98 | if command -v auditctl >/dev/null 2>&1; then 99 | if auditctl -l | grep "$file" >/dev/null 2>&1; then 100 | pass "$check_1_5" 101 | resulttestjson "PASS" 102 | currentScore=$((currentScore + 1)) 103 | else 104 | warn "$check_1_5" 105 | resulttestjson "WARN" 106 | currentScore=$((currentScore - 1)) 107 | fi 108 | elif grep -s "$file" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then 109 | pass "$check_1_5" 110 | resulttestjson "PASS" 111 | currentScore=$((currentScore + 1)) 112 | else 113 | warn "$check_1_5" 114 | resulttestjson "WARN" 115 | currentScore=$((currentScore - 1)) 116 | fi 117 | } 118 | 119 | # 1.6 120 | check_1_6() { 121 | id_1_6="1.6" 122 | desc_1_6="Ensure auditing is configured for Docker files and directories - /var/lib/docker" 123 | check_1_6="$id_1_6 - $desc_1_6" 124 | starttestjson "$id_1_6" "$desc_1_6" 125 | 126 | totalChecks=$((totalChecks + 1)) 127 | directory="/var/lib/docker" 128 | if [ -d "$directory" ]; then 129 | if command -v auditctl >/dev/null 2>&1; then 130 | if auditctl -l | grep $directory >/dev/null 2>&1; then 131 | pass "$check_1_6" 132 | resulttestjson "PASS" 133 | currentScore=$((currentScore + 1)) 134 | else 135 | warn "$check_1_6" 136 | resulttestjson "WARN" 137 | currentScore=$((currentScore - 1)) 138 | fi 139 | elif grep -s "$directory" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then 140 | pass "$check_1_6" 141 | resulttestjson "PASS" 142 | currentScore=$((currentScore + 1)) 143 | else 144 | warn "$check_1_6" 145 | resulttestjson "WARN" 146 | currentScore=$((currentScore - 1)) 147 | fi 148 | else 149 | info "$check_1_6" 150 | info " * Directory not found" 151 | resulttestjson "INFO" "Directory not found" 152 | currentScore=$((currentScore + 0)) 153 | fi 154 | } 155 | 156 | # 1.7 157 | check_1_7() { 158 | id_1_7="1.7" 159 | desc_1_7="Ensure auditing is configured for Docker files and directories - /etc/docker" 160 | check_1_7="$id_1_7 - $desc_1_7" 161 | starttestjson "$id_1_7" "$desc_1_7" 162 | 163 | totalChecks=$((totalChecks + 1)) 164 | directory="/etc/docker" 165 | if [ -d "$directory" ]; then 166 | if command -v auditctl >/dev/null 2>&1; then 167 | if auditctl -l | grep $directory >/dev/null 2>&1; then 168 | pass "$check_1_7" 169 | resulttestjson "PASS" 170 | currentScore=$((currentScore + 1)) 171 | else 172 | warn "$check_1_7" 173 | resulttestjson "WARN" 174 | currentScore=$((currentScore - 1)) 175 | fi 176 | elif grep -s "$directory" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then 177 | pass "$check_1_7" 178 | resulttestjson "PASS" 179 | currentScore=$((currentScore + 1)) 180 | else 181 | warn "$check_1_7" 182 | resulttestjson "WARN" 183 | currentScore=$((currentScore - 1)) 184 | fi 185 | else 186 | info "$check_1_7" 187 | info " * Directory not found" 188 | resulttestjson "INFO" "Directory not found" 189 | currentScore=$((currentScore + 0)) 190 | fi 191 | } 192 | 193 | # 1.8 194 | check_1_8() { 195 | id_1_8="1.8" 196 | desc_1_8="Ensure auditing is configured for Docker files and directories - docker.service" 197 | check_1_8="$id_1_8 - $desc_1_8" 198 | starttestjson "$id_1_8" "$desc_1_8" 199 | 200 | totalChecks=$((totalChecks + 1)) 201 | file="$(get_systemd_service_file docker.service)" 202 | if [ -f "$file" ]; then 203 | if command -v auditctl >/dev/null 2>&1; then 204 | if auditctl -l | grep "$file" >/dev/null 2>&1; then 205 | pass "$check_1_8" 206 | resulttestjson "PASS" 207 | currentScore=$((currentScore + 1)) 208 | else 209 | warn "$check_1_8" 210 | resulttestjson "WARN" 211 | currentScore=$((currentScore - 1)) 212 | fi 213 | elif grep -s "$file" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then 214 | pass "$check_1_8" 215 | resulttestjson "PASS" 216 | currentScore=$((currentScore + 1)) 217 | else 218 | warn "$check_1_8" 219 | resulttestjson "WARN" 220 | currentScore=$((currentScore - 1)) 221 | fi 222 | else 223 | info "$check_1_8" 224 | info " * File not found" 225 | resulttestjson "INFO" "File not found" 226 | currentScore=$((currentScore + 0)) 227 | fi 228 | } 229 | 230 | # 1.9 231 | check_1_9() { 232 | id_1_9="1.9" 233 | desc_1_9="Ensure auditing is configured for Docker files and directories - docker.socket" 234 | check_1_9="$id_1_9 - $desc_1_9" 235 | starttestjson "$id_1_9" "$desc_1_9" 236 | 237 | totalChecks=$((totalChecks + 1)) 238 | file="$(get_systemd_service_file docker.socket)" 239 | if [ -e "$file" ]; then 240 | if command -v auditctl >/dev/null 2>&1; then 241 | if auditctl -l | grep "$file" >/dev/null 2>&1; then 242 | pass "$check_1_9" 243 | resulttestjson "PASS" 244 | currentScore=$((currentScore + 1)) 245 | else 246 | warn "$check_1_9" 247 | resulttestjson "WARN" 248 | currentScore=$((currentScore - 1)) 249 | fi 250 | elif grep -s "$file" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then 251 | pass "$check_1_9" 252 | resulttestjson "PASS" 253 | currentScore=$((currentScore + 1)) 254 | else 255 | warn "$check_1_9" 256 | resulttestjson "WARN" 257 | currentScore=$((currentScore - 1)) 258 | fi 259 | else 260 | info "$check_1_9" 261 | info " * File not found" 262 | resulttestjson "INFO" "File not found" 263 | currentScore=$((currentScore + 0)) 264 | fi 265 | } 266 | 267 | # 1.10 268 | check_1_10() { 269 | id_1_10="1.10" 270 | desc_1_10="Ensure auditing is configured for Docker files and directories - /etc/default/docker" 271 | check_1_10="$id_1_10 - $desc_1_10" 272 | starttestjson "$id_1_10" "$desc_1_10" 273 | 274 | totalChecks=$((totalChecks + 1)) 275 | file="/etc/default/docker" 276 | if [ -f "$file" ]; then 277 | if command -v auditctl >/dev/null 2>&1; then 278 | if auditctl -l | grep $file >/dev/null 2>&1; then 279 | pass "$check_1_10" 280 | resulttestjson "PASS" 281 | currentScore=$((currentScore + 1)) 282 | else 283 | warn "$check_1_10" 284 | resulttestjson "WARN" 285 | currentScore=$((currentScore - 1)) 286 | fi 287 | elif grep -s "$file" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then 288 | pass "$check_1_10" 289 | resulttestjson "PASS" 290 | currentScore=$((currentScore + 1)) 291 | else 292 | warn "$check_1_10" 293 | resulttestjson "WARN" 294 | currentScore=$((currentScore - 1)) 295 | fi 296 | else 297 | info "$check_1_10" 298 | info " * File not found" 299 | resulttestjson "INFO" "File not found" 300 | currentScore=$((currentScore + 0)) 301 | fi 302 | } 303 | 304 | # 1.11 305 | check_1_11() { 306 | id_1_11="1.11" 307 | desc_1_11="Ensure auditing is configured for Docker files and directories - /etc/docker/daemon.json" 308 | check_1_11="$id_1_11 - $desc_1_11" 309 | starttestjson "$id_1_11" "$desc_1_11" 310 | 311 | totalChecks=$((totalChecks + 1)) 312 | file="/etc/docker/daemon.json" 313 | if [ -f "$file" ]; then 314 | if command -v auditctl >/dev/null 2>&1; then 315 | if auditctl -l | grep $file >/dev/null 2>&1; then 316 | pass "$check_1_11" 317 | resulttestjson "PASS" 318 | currentScore=$((currentScore + 1)) 319 | else 320 | warn "$check_1_11" 321 | resulttestjson "WARN" 322 | currentScore=$((currentScore - 1)) 323 | fi 324 | elif grep -s "$file" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then 325 | pass "$check_1_11" 326 | resulttestjson "PASS" 327 | currentScore=$((currentScore + 1)) 328 | else 329 | warn "$check_1_11" 330 | resulttestjson "WARN" 331 | currentScore=$((currentScore - 1)) 332 | fi 333 | else 334 | info "$check_1_11" 335 | info " * File not found" 336 | resulttestjson "INFO" "File not found" 337 | currentScore=$((currentScore + 0)) 338 | fi 339 | } 340 | 341 | # 1.12 342 | check_1_12() { 343 | id_1_12="1.12" 344 | desc_1_12="Ensure auditing is configured for Docker files and directories - /usr/bin/docker-containerd" 345 | check_1_12="$id_1_12 - $desc_1_12" 346 | starttestjson "$id_1_12" "$desc_1_12" 347 | 348 | totalChecks=$((totalChecks + 1)) 349 | file="/usr/bin/docker-containerd" 350 | if [ -f "$file" ]; then 351 | if command -v auditctl >/dev/null 2>&1; then 352 | if auditctl -l | grep $file >/dev/null 2>&1; then 353 | pass "$check_1_12" 354 | resulttestjson "PASS" 355 | currentScore=$((currentScore + 1)) 356 | else 357 | warn "$check_1_12" 358 | resulttestjson "WARN" 359 | currentScore=$((currentScore - 1)) 360 | fi 361 | elif grep -s "$file" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then 362 | pass "$check_1_12" 363 | resulttestjson "PASS" 364 | currentScore=$((currentScore + 1)) 365 | else 366 | warn "$check_1_12" 367 | resulttestjson "WARN" 368 | currentScore=$((currentScore - 1)) 369 | fi 370 | else 371 | info "$check_1_12" 372 | info " * File not found" 373 | resulttestjson "INFO" "File not found" 374 | currentScore=$((currentScore + 0)) 375 | fi 376 | } 377 | 378 | # 1.13 379 | check_1_13() { 380 | id_1_13="1.13" 381 | desc_1_13="Ensure auditing is configured for Docker files and directories - /usr/bin/docker-runc" 382 | check_1_13="$id_1_13 - $desc_1_13" 383 | starttestjson "$id_1_13" "$desc_1_13" 384 | 385 | totalChecks=$((totalChecks + 1)) 386 | file="/usr/bin/docker-runc" 387 | if [ -f "$file" ]; then 388 | if command -v auditctl >/dev/null 2>&1; then 389 | if auditctl -l | grep $file >/dev/null 2>&1; then 390 | pass "$check_1_13" 391 | resulttestjson "PASS" 392 | currentScore=$((currentScore + 1)) 393 | else 394 | warn "$check_1_13" 395 | resulttestjson "WARN" 396 | currentScore=$((currentScore - 1)) 397 | fi 398 | elif grep -s "$file" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then 399 | pass "$check_1_13" 400 | resulttestjson "PASS" 401 | currentScore=$((currentScore + 1)) 402 | else 403 | warn "$check_1_13" 404 | resulttestjson "WARN" 405 | currentScore=$((currentScore - 1)) 406 | fi 407 | else 408 | info "$check_1_13" 409 | info " * File not found" 410 | resulttestjson "INFO" "File not found" 411 | currentScore=$((currentScore + 0)) 412 | fi 413 | } 414 | 415 | check_1_end() { 416 | endsectionjson 417 | } 418 | 419 | -------------------------------------------------------------------------------- /csf_client/tests/2_docker_daemon_configuration.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | check_2() { 4 | logit "\n" 5 | id_2="2" 6 | desc_2="Docker daemon configuration" 7 | check_2="$id_2 - $desc_2" 8 | info "$check_2" 9 | startsectionjson "$id_2" "$desc_2" 10 | } 11 | 12 | # 2.1 13 | check_2_1() { 14 | id_2_1="2.1" 15 | desc_2_1="Ensure network traffic is restricted between containers on the default bridge" 16 | check_2_1="$id_2_1 - $desc_2_1" 17 | starttestjson "$id_2_1" "$desc_2_1" 18 | 19 | totalChecks=$((totalChecks + 1)) 20 | if get_docker_effective_command_line_args '--icc' | grep false >/dev/null 2>&1; then 21 | pass "$check_2_1" 22 | resulttestjson "PASS" 23 | currentScore=$((currentScore + 1)) 24 | elif get_docker_configuration_file_args 'icc' | grep "false" >/dev/null 2>&1; then 25 | pass "$check_2_1" 26 | resulttestjson "PASS" 27 | currentScore=$((currentScore + 1)) 28 | else 29 | warn "$check_2_1" 30 | resulttestjson "WARN" 31 | currentScore=$((currentScore - 1)) 32 | fi 33 | } 34 | 35 | # 2.2 36 | check_2_2() { 37 | id_2_2="2.2" 38 | desc_2_2="Ensure the logging level is set to 'info'" 39 | check_2_2="$id_2_2 - $desc_2_2" 40 | starttestjson "$id_2_2" "$desc_2_2" 41 | 42 | totalChecks=$((totalChecks + 1)) 43 | if get_docker_configuration_file_args 'log-level' >/dev/null 2>&1; then 44 | if get_docker_configuration_file_args 'log-level' | grep info >/dev/null 2>&1; then 45 | pass "$check_2_2" 46 | resulttestjson "PASS" 47 | currentScore=$((currentScore + 1)) 48 | elif [ -z "$(get_docker_configuration_file_args 'log-level')" ]; then 49 | pass "$check_2_2" 50 | resulttestjson "PASS" 51 | currentScore=$((currentScore + 1)) 52 | else 53 | warn "$check_2_2" 54 | resulttestjson "WARN" 55 | currentScore=$((currentScore - 1)) 56 | fi 57 | elif get_docker_effective_command_line_args '-l'; then 58 | if get_docker_effective_command_line_args '-l' | grep "info" >/dev/null 2>&1; then 59 | pass "$check_2_2" 60 | resulttestjson "PASS" 61 | currentScore=$((currentScore + 1)) 62 | else 63 | warn "$check_2_2" 64 | resulttestjson "WARN" 65 | currentScore=$((currentScore - 1)) 66 | fi 67 | else 68 | pass "$check_2_2" 69 | resulttestjson "PASS" 70 | currentScore=$((currentScore + 1)) 71 | fi 72 | } 73 | 74 | # 2.3 75 | check_2_3() { 76 | id_2_3="2.3" 77 | desc_2_3="Ensure Docker is allowed to make changes to iptables" 78 | check_2_3="$id_2_3 - $desc_2_3" 79 | starttestjson "$id_2_3" "$desc_2_3" 80 | 81 | totalChecks=$((totalChecks + 1)) 82 | if get_docker_effective_command_line_args '--iptables' | grep "false" >/dev/null 2>&1; then 83 | warn "$check_2_3" 84 | resulttestjson "WARN" 85 | currentScore=$((currentScore - 1)) 86 | elif get_docker_configuration_file_args 'iptables' | grep "false" >/dev/null 2>&1; then 87 | warn "$check_2_3" 88 | resulttestjson "WARN" 89 | currentScore=$((currentScore - 1)) 90 | else 91 | pass "$check_2_3" 92 | resulttestjson "PASS" 93 | currentScore=$((currentScore + 1)) 94 | fi 95 | } 96 | 97 | # 2.4 98 | check_2_4() { 99 | id_2_4="2.4" 100 | desc_2_4="Ensure insecure registries are not used" 101 | check_2_4="$id_2_4 - $desc_2_4" 102 | starttestjson "$id_2_4" "$desc_2_4" 103 | 104 | totalChecks=$((totalChecks + 1)) 105 | if get_docker_effective_command_line_args '--insecure-registry' | grep "insecure-registry" >/dev/null 2>&1; then 106 | warn "$check_2_4" 107 | resulttestjson "WARN" 108 | currentScore=$((currentScore - 1)) 109 | elif ! [ -z "$(get_docker_configuration_file_args 'insecure-registries')" ]; then 110 | if get_docker_configuration_file_args 'insecure-registries' | grep '\[]' >/dev/null 2>&1; then 111 | pass "$check_2_4" 112 | resulttestjson "PASS" 113 | currentScore=$((currentScore + 1)) 114 | else 115 | warn "$check_2_4" 116 | resulttestjson "WARN" 117 | currentScore=$((currentScore - 1)) 118 | fi 119 | else 120 | pass "$check_2_4" 121 | resulttestjson "PASS" 122 | currentScore=$((currentScore + 1)) 123 | fi 124 | } 125 | 126 | # 2.5 127 | check_2_5() { 128 | id_2_5="2.5" 129 | desc_2_5="Ensure aufs storage driver is not used" 130 | check_2_5="$id_2_5 - $desc_2_5" 131 | starttestjson "$id_2_5" "$desc_2_5" 132 | 133 | totalChecks=$((totalChecks + 1)) 134 | if docker info 2>/dev/null | grep -e "^Storage Driver:\s*aufs\s*$" >/dev/null 2>&1; then 135 | warn "$check_2_5" 136 | resulttestjson "WARN" 137 | currentScore=$((currentScore - 1)) 138 | else 139 | pass "$check_2_5" 140 | resulttestjson "PASS" 141 | currentScore=$((currentScore + 1)) 142 | fi 143 | } 144 | 145 | # 2.6 146 | check_2_6() { 147 | id_2_6="2.6" 148 | desc_2_6="Ensure TLS authentication for Docker daemon is configured" 149 | check_2_6="$id_2_6 - $desc_2_6" 150 | starttestjson "$id_2_6" "$desc_2_6" 151 | 152 | totalChecks=$((totalChecks + 1)) 153 | if [ grep -i 'tcp://' "$CONFIG_FILE" 2>/dev/null 1>&2 ] || \ 154 | [ $(get_docker_cumulative_command_line_args '-H' | grep -vE '(unix|fd)://') >/dev/null 2>&1 ]; then 155 | if [ $(get_docker_configuration_file_args '"tlsverify":' | grep 'true') ] || \ 156 | [ $(get_docker_cumulative_command_line_args '--tlsverify' | grep 'tlsverify') >/dev/null 2>&1 ]; then 157 | pass "$check_2_6" 158 | resulttestjson "PASS" 159 | currentScore=$((currentScore + 1)) 160 | elif [ $(get_docker_configuration_file_args '"tls":' | grep 'true') ] || \ 161 | [ $(get_docker_cumulative_command_line_args '--tls' | grep 'tls$') >/dev/null 2>&1 ]; then 162 | warn "$check_2_6" 163 | warn " * Docker daemon currently listening on TCP with TLS, but no verification" 164 | resulttestjson "WARN" "Docker daemon currently listening on TCP with TLS, but no verification" 165 | currentScore=$((currentScore - 1)) 166 | else 167 | warn "$check_2_6" 168 | warn " * Docker daemon currently listening on TCP without TLS" 169 | resulttestjson "WARN" "Docker daemon currently listening on TCP without TLS" 170 | currentScore=$((currentScore - 1)) 171 | fi 172 | else 173 | info "$check_2_6" 174 | info " * Docker daemon not listening on TCP" 175 | resulttestjson "INFO" "Docker daemon not listening on TCP" 176 | currentScore=$((currentScore + 0)) 177 | fi 178 | } 179 | 180 | # 2.7 181 | check_2_7() { 182 | id_2_7="2.7" 183 | desc_2_7="Ensure the default ulimit is configured appropriately" 184 | check_2_7="$id_2_7 - $desc_2_7" 185 | starttestjson "$id_2_7" "$desc_2_7" 186 | 187 | totalChecks=$((totalChecks + 1)) 188 | if get_docker_configuration_file_args 'default-ulimit' | grep -v '{}' >/dev/null 2>&1; then 189 | pass "$check_2_7" 190 | resulttestjson "PASS" 191 | currentScore=$((currentScore + 1)) 192 | elif get_docker_effective_command_line_args '--default-ulimit' | grep "default-ulimit" >/dev/null 2>&1; then 193 | pass "$check_2_7" 194 | resulttestjson "PASS" 195 | currentScore=$((currentScore + 1)) 196 | else 197 | info "$check_2_7" 198 | info " * Default ulimit doesn't appear to be set" 199 | resulttestjson "INFO" "Default ulimit doesn't appear to be set" 200 | currentScore=$((currentScore + 0)) 201 | fi 202 | } 203 | 204 | # 2.8 205 | check_2_8() { 206 | id_2_8="2.8" 207 | desc_2_8="Enable user namespace support" 208 | check_2_8="$id_2_8 - $desc_2_8" 209 | starttestjson "$id_2_8" "$desc_2_8" 210 | 211 | totalChecks=$((totalChecks + 1)) 212 | if get_docker_configuration_file_args 'userns-remap' | grep -v '""'; then 213 | pass "$check_2_8" 214 | resulttestjson "PASS" 215 | currentScore=$((currentScore + 1)) 216 | elif get_docker_effective_command_line_args '--userns-remap' | grep "userns-remap" >/dev/null 2>&1; then 217 | pass "$check_2_8" 218 | resulttestjson "PASS" 219 | currentScore=$((currentScore + 1)) 220 | else 221 | warn "$check_2_8" 222 | resulttestjson "WARN" 223 | currentScore=$((currentScore - 1)) 224 | fi 225 | } 226 | 227 | # 2.9 228 | check_2_9() { 229 | id_2_9="2.9" 230 | desc_2_9="Ensure the default cgroup usage has been confirmed" 231 | check_2_9="$id_2_9 - $desc_2_9" 232 | starttestjson "$id_2_9" "$desc_2_9" 233 | 234 | totalChecks=$((totalChecks + 1)) 235 | if get_docker_configuration_file_args 'cgroup-parent' | grep -v '""'; then 236 | warn "$check_2_9" 237 | info " * Confirm cgroup usage" 238 | resulttestjson "WARN" "Confirm cgroup usage" 239 | currentScore=$((currentScore + 0)) 240 | elif get_docker_effective_command_line_args '--cgroup-parent' | grep "cgroup-parent" >/dev/null 2>&1; then 241 | warn "$check_2_9" 242 | info " * Confirm cgroup usage" 243 | resulttestjson "WARN" "Confirm cgroup usage" 244 | currentScore=$((currentScore + 0)) 245 | else 246 | pass "$check_2_9" 247 | resulttestjson "PASS" 248 | currentScore=$((currentScore + 1)) 249 | fi 250 | } 251 | 252 | # 2.10 253 | check_2_10() { 254 | id_2_10="2.10" 255 | desc_2_10="Ensure base device size is not changed until needed" 256 | check_2_10="$id_2_10 - $desc_2_10" 257 | starttestjson "$id_2_10" "$desc_2_10" 258 | 259 | totalChecks=$((totalChecks + 1)) 260 | if get_docker_configuration_file_args 'storage-opts' | grep "dm.basesize" >/dev/null 2>&1; then 261 | warn "$check_2_10" 262 | resulttestjson "WARN" 263 | currentScore=$((currentScore - 1)) 264 | elif get_docker_effective_command_line_args '--storage-opt' | grep "dm.basesize" >/dev/null 2>&1; then 265 | warn "$check_2_10" 266 | resulttestjson "WARN" 267 | currentScore=$((currentScore - 1)) 268 | else 269 | pass "$check_2_10" 270 | resulttestjson "PASS" 271 | currentScore=$((currentScore + 1)) 272 | fi 273 | } 274 | 275 | # 2.11 276 | check_2_11() { 277 | id_2_11="2.11" 278 | desc_2_11="Ensure that authorization for Docker client commands is enabled" 279 | check_2_11="$id_2_11 - $desc_2_11" 280 | starttestjson "$id_2_11" "$desc_2_11" 281 | 282 | totalChecks=$((totalChecks + 1)) 283 | if get_docker_configuration_file_args 'authorization-plugins' | grep -v '\[]'; then 284 | pass "$check_2_11" 285 | resulttestjson "PASS" 286 | currentScore=$((currentScore + 1)) 287 | elif get_docker_effective_command_line_args '--authorization-plugin' | grep "authorization-plugin" >/dev/null 2>&1; then 288 | pass "$check_2_11" 289 | resulttestjson "PASS" 290 | currentScore=$((currentScore + 1)) 291 | else 292 | warn "$check_2_11" 293 | resulttestjson "WARN" 294 | currentScore=$((currentScore - 1)) 295 | fi 296 | } 297 | 298 | # 2.12 299 | check_2_12() { 300 | id_2_12="2.12" 301 | desc_2_12="Ensure centralized and remote logging is configured" 302 | check_2_12="$id_2_12 - $desc_2_12" 303 | starttestjson "$id_2_12" "$desc_2_12" 304 | 305 | totalChecks=$((totalChecks + 1)) 306 | if docker info --format '{{ .LoggingDriver }}' | grep 'json-file' >/dev/null 2>&1; then 307 | warn "$check_2_12" 308 | resulttestjson "WARN" 309 | currentScore=$((currentScore - 1)) 310 | else 311 | pass "$check_2_12" 312 | resulttestjson "PASS" 313 | currentScore=$((currentScore + 1)) 314 | fi 315 | } 316 | 317 | # 2.13 318 | check_2_13() { 319 | docker_version=$(docker version | grep -i -A2 '^server' | grep ' Version:' \ 320 | | awk '{print $NF; exit}' | tr -d '[:alpha:]-,.') 321 | totalChecks=$((totalChecks + 1)) 322 | 323 | id_2_13="2.13" 324 | desc_2_13="Ensure operations on legacy registry (v1) are Disabled" 325 | check_2_13="$id_2_13 - $desc_2_13" 326 | starttestjson "$id_2_13" "$desc_2_13" 327 | 328 | if [ "$docker_version" -lt 1712 ]; then 329 | if get_docker_configuration_file_args 'disable-legacy-registry' | grep 'true' >/dev/null 2>&1; then 330 | pass "$check_2_13" 331 | resulttestjson "PASS" 332 | currentScore=$((currentScore + 1)) 333 | elif get_docker_effective_command_line_args '--disable-legacy-registry' | grep "disable-legacy-registry" >/dev/null 2>&1; then 334 | pass "$check_2_13" 335 | resulttestjson "PASS" 336 | currentScore=$((currentScore + 1)) 337 | else 338 | warn "$check_2_13" 339 | resulttestjson "WARN" 340 | currentScore=$((currentScore - 1)) 341 | fi 342 | else 343 | desc_2_13="$desc_2_13 (Deprecated)" 344 | check_2_13="$id_2_13 - $desc_2_13" 345 | info "$check_2_13" 346 | resulttestjson "INFO" 347 | fi 348 | } 349 | 350 | # 2.14 351 | check_2_14() { 352 | id_2_14="2.14" 353 | desc_2_14="Ensure live restore is Enabled" 354 | check_2_14="$id_2_14 - $desc_2_14" 355 | starttestjson "$id_2_14" "$desc_2_14" 356 | 357 | totalChecks=$((totalChecks + 1)) 358 | if docker info 2>/dev/null | grep -e "Live Restore Enabled:\s*true\s*" >/dev/null 2>&1; then 359 | pass "$check_2_14" 360 | resulttestjson "PASS" 361 | currentScore=$((currentScore + 1)) 362 | else 363 | if docker info 2>/dev/null | grep -e "Swarm:*\sactive\s*" >/dev/null 2>&1; then 364 | pass "$check_2_14 (Incompatible with swarm mode)" 365 | resulttestjson "PASS" 366 | currentScore=$((currentScore + 1)) 367 | elif get_docker_effective_command_line_args '--live-restore' | grep "live-restore" >/dev/null 2>&1; then 368 | pass "$check_2_14" 369 | resulttestjson "PASS" 370 | currentScore=$((currentScore + 1)) 371 | else 372 | warn "$check_2_14" 373 | resulttestjson "WARN" 374 | currentScore=$((currentScore - 1)) 375 | fi 376 | fi 377 | } 378 | 379 | # 2.15 380 | check_2_15() { 381 | id_2_15="2.15" 382 | desc_2_15="Ensure Userland Proxy is Disabled" 383 | check_2_15="$id_2_15 - $desc_2_15" 384 | starttestjson "$id_2_15" "$desc_2_15" 385 | 386 | totalChecks=$((totalChecks + 1)) 387 | if get_docker_configuration_file_args 'userland-proxy' | grep false >/dev/null 2>&1; then 388 | pass "$check_2_15" 389 | resulttestjson "PASS" 390 | currentScore=$((currentScore + 1)) 391 | elif get_docker_effective_command_line_args '--userland-proxy=false' 2>/dev/null | grep "userland-proxy=false" >/dev/null 2>&1; then 392 | pass "$check_2_15" 393 | resulttestjson "PASS" 394 | currentScore=$((currentScore + 1)) 395 | else 396 | warn "$check_2_15" 397 | resulttestjson "WARN" 398 | currentScore=$((currentScore - 1)) 399 | fi 400 | } 401 | 402 | # 2.16 403 | check_2_16() { 404 | id_2_16="2.16" 405 | desc_2_16="Ensure daemon-wide custom seccomp profile is applied, if needed" 406 | check_2_16="$id_2_16 - $desc_2_16" 407 | starttestjson "$id_2_16" "$desc_2_16" 408 | 409 | totalChecks=$((totalChecks + 1)) 410 | if docker info --format '{{ .SecurityOptions }}' | grep 'name=seccomp,profile=default' 2>/dev/null 1>&2; then 411 | pass "$check_2_16" 412 | resulttestjson "PASS" 413 | currentScore=$((currentScore + 1)) 414 | else 415 | info "$check_2_16" 416 | resulttestjson "INFO" 417 | currentScore=$((currentScore + 0)) 418 | fi 419 | } 420 | 421 | # 2.17 422 | check_2_17() { 423 | id_2_17="2.17" 424 | desc_2_17="Ensure experimental features are avoided in production" 425 | check_2_17="$id_2_17 - $desc_2_17" 426 | starttestjson "$id_2_17" "$desc_2_17" 427 | 428 | totalChecks=$((totalChecks + 1)) 429 | if docker version -f '{{.Server.Experimental}}' | grep false 2>/dev/null 1>&2; then 430 | pass "$check_2_17" 431 | resulttestjson "PASS" 432 | currentScore=$((currentScore + 1)) 433 | else 434 | warn "$check_2_17" 435 | resulttestjson "WARN" 436 | currentScore=$((currentScore - 1)) 437 | fi 438 | } 439 | 440 | # 2.18 441 | check_2_18() { 442 | id_2_18="2.18" 443 | desc_2_18="Ensure containers are restricted from acquiring new privileges" 444 | check_2_18="$id_2_18 - $desc_2_18" 445 | starttestjson "$id_2_18" "$desc_2_18" 446 | 447 | totalChecks=$((totalChecks + 1)) 448 | if get_docker_effective_command_line_args '--no-new-privileges' | grep "no-new-privileges" >/dev/null 2>&1; then 449 | pass "$check_2_18" 450 | resulttestjson "PASS" 451 | currentScore=$((currentScore + 1)) 452 | elif get_docker_configuration_file_args 'no-new-privileges' | grep true >/dev/null 2>&1; then 453 | pass "$check_2_18" 454 | resulttestjson "PASS" 455 | currentScore=$((currentScore + 1)) 456 | else 457 | warn "$check_2_18" 458 | resulttestjson "WARN" 459 | currentScore=$((currentScore - 1)) 460 | fi 461 | } 462 | 463 | check_2_end() { 464 | endsectionjson 465 | } 466 | -------------------------------------------------------------------------------- /csf_client/tests/3_docker_daemon_configuration_files.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | check_3() { 4 | logit "\n" 5 | id_3="3" 6 | desc_3="Docker daemon configuration files" 7 | check_3="$id_3 - $desc_3" 8 | info "$check_3" 9 | startsectionjson "$id_3" "$desc_3" 10 | } 11 | 12 | # 3.1 13 | check_3_1() { 14 | id_3_1="3.1" 15 | desc_3_1="Ensure that docker.service file ownership is set to root:root" 16 | check_3_1="$id_3_1 - $desc_3_1" 17 | starttestjson "$id_3_1" "$desc_3_1" 18 | 19 | totalChecks=$((totalChecks + 1)) 20 | file="$(get_systemd_service_file docker.service)" 21 | if [ -f "$file" ]; then 22 | if [ "$(stat -c %u%g $file)" -eq 00 ]; then 23 | pass "$check_3_1" 24 | resulttestjson "PASS" 25 | currentScore=$((currentScore + 1)) 26 | else 27 | warn "$check_3_1" 28 | warn " * Wrong ownership for $file" 29 | resulttestjson "WARN" "Wrong ownership for $file" 30 | currentScore=$((currentScore - 1)) 31 | fi 32 | else 33 | info "$check_3_1" 34 | info " * File not found" 35 | resulttestjson "INFO" "File not found" 36 | currentScore=$((currentScore + 0)) 37 | fi 38 | } 39 | 40 | # 3.2 41 | check_3_2() { 42 | id_3_2="3.2" 43 | desc_3_2="Ensure that docker.service file permissions are set to 644 or more restrictive" 44 | check_3_2="$id_3_2 - $desc_3_2" 45 | starttestjson "$id_3_2" "$desc_3_2" 46 | 47 | totalChecks=$((totalChecks + 1)) 48 | file="$(get_systemd_service_file docker.service)" 49 | if [ -f "$file" ]; then 50 | if [ "$(stat -c %a $file)" -eq 644 ] || [ "$(stat -c %a $file)" -eq 600 ]; then 51 | pass "$check_3_2" 52 | resulttestjson "PASS" 53 | currentScore=$((currentScore + 1)) 54 | else 55 | warn "$check_3_2" 56 | warn " * Wrong permissions for $file" 57 | resulttestjson "WARN" "Wrong permissions for $file" 58 | currentScore=$((currentScore - 1)) 59 | fi 60 | else 61 | info "$check_3_2" 62 | info " * File not found" 63 | resulttestjson "INFO" "File not found" 64 | currentScore=$((currentScore + 0)) 65 | fi 66 | } 67 | 68 | # 3.3 69 | check_3_3() { 70 | id_3_3="3.3" 71 | desc_3_3="Ensure that docker.socket file ownership is set to root:root" 72 | check_3_3="$id_3_3 - $desc_3_3" 73 | starttestjson "$id_3_3" "$desc_3_3" 74 | 75 | totalChecks=$((totalChecks + 1)) 76 | file="$(get_systemd_service_file docker.socket)" 77 | if [ -f "$file" ]; then 78 | if [ "$(stat -c %u%g $file)" -eq 00 ]; then 79 | pass "$check_3_3" 80 | resulttestjson "PASS" 81 | currentScore=$((currentScore + 1)) 82 | else 83 | warn "$check_3_3" 84 | warn " * Wrong ownership for $file" 85 | resulttestjson "WARN" "Wrong ownership for $file" 86 | currentScore=$((currentScore - 1)) 87 | fi 88 | else 89 | info "$check_3_3" 90 | info " * File not found" 91 | resulttestjson "INFO" "File not found" 92 | currentScore=$((currentScore + 0)) 93 | fi 94 | } 95 | 96 | # 3.4 97 | check_3_4() { 98 | id_3_4="3.4" 99 | desc_3_4="Ensure that docker.socket file permissions are set to 644 or more restrictive" 100 | check_3_4="$id_3_4 - $desc_3_4" 101 | starttestjson "$id_3_4" "$desc_3_4" 102 | 103 | totalChecks=$((totalChecks + 1)) 104 | file="$(get_systemd_service_file docker.socket)" 105 | if [ -f "$file" ]; then 106 | if [ "$(stat -c %a $file)" -eq 644 ] || [ "$(stat -c %a $file)" -eq 600 ]; then 107 | pass "$check_3_4" 108 | resulttestjson "PASS" 109 | currentScore=$((currentScore + 1)) 110 | else 111 | warn "$check_3_4" 112 | warn " * Wrong permissions for $file" 113 | resulttestjson "WARN" "Wrong permissions for $file" 114 | currentScore=$((currentScore - 1)) 115 | fi 116 | else 117 | info "$check_3_4" 118 | info " * File not found" 119 | resulttestjson "INFO" "File not found" 120 | currentScore=$((currentScore + 0)) 121 | fi 122 | } 123 | 124 | # 3.5 125 | check_3_5() { 126 | id_3_5="3.5" 127 | desc_3_5="Ensure that /etc/docker directory ownership is set to root:root" 128 | check_3_5="$id_3_5 - $desc_3_5" 129 | starttestjson "$id_3_5" "$desc_3_5" 130 | 131 | totalChecks=$((totalChecks + 1)) 132 | directory="/etc/docker" 133 | if [ -d "$directory" ]; then 134 | if [ "$(stat -c %u%g $directory)" -eq 00 ]; then 135 | pass "$check_3_5" 136 | resulttestjson "PASS" 137 | currentScore=$((currentScore + 1)) 138 | else 139 | warn "$check_3_5" 140 | warn " * Wrong ownership for $directory" 141 | resulttestjson "WARN" "Wrong ownership for $directory" 142 | currentScore=$((currentScore - 1)) 143 | fi 144 | else 145 | info "$check_3_5" 146 | info " * Directory not found" 147 | resulttestjson "INFO" "Directory not found" 148 | currentScore=$((currentScore + 0)) 149 | fi 150 | } 151 | 152 | # 3.6 153 | check_3_6() { 154 | id_3_6="3.6" 155 | desc_3_6="Ensure that /etc/docker directory permissions are set to 755 or more restrictive" 156 | check_3_6="$id_3_6 - $desc_3_6" 157 | starttestjson "$id_3_6" "$desc_3_6" 158 | 159 | totalChecks=$((totalChecks + 1)) 160 | directory="/etc/docker" 161 | if [ -d "$directory" ]; then 162 | if [ "$(stat -c %a $directory)" -eq 755 ] || [ "$(stat -c %a $directory)" -eq 700 ]; then 163 | pass "$check_3_6" 164 | resulttestjson "PASS" 165 | currentScore=$((currentScore + 1)) 166 | else 167 | warn "$check_3_6" 168 | warn " * Wrong permissions for $directory" 169 | resulttestjson "WARN" "Wrong permissions for $directory" 170 | currentScore=$((currentScore - 1)) 171 | fi 172 | else 173 | info "$check_3_6" 174 | info " * Directory not found" 175 | resulttestjson "INFO" "Directory not found" 176 | currentScore=$((currentScore + 0)) 177 | fi 178 | } 179 | 180 | # 3.7 181 | check_3_7() { 182 | id_3_7="3.7" 183 | desc_3_7="Ensure that registry certificate file ownership is set to root:root" 184 | check_3_7="$id_3_7 - $desc_3_7" 185 | starttestjson "$id_3_7" "$desc_3_7" 186 | 187 | totalChecks=$((totalChecks + 1)) 188 | directory="/etc/docker/certs.d/" 189 | if [ -d "$directory" ]; then 190 | fail=0 191 | owners=$(find "$directory" -type f -name '*.crt') 192 | for p in $owners; do 193 | if [ "$(stat -c %u $p)" -ne 0 ]; then 194 | fail=1 195 | fi 196 | done 197 | if [ $fail -eq 1 ]; then 198 | warn "$check_3_7" 199 | warn " * Wrong ownership for $directory" 200 | resulttestjson "WARN" "Wrong ownership for $directory" 201 | currentScore=$((currentScore - 1)) 202 | else 203 | pass "$check_3_7" 204 | resulttestjson "PASS" 205 | currentScore=$((currentScore + 1)) 206 | fi 207 | else 208 | info "$check_3_7" 209 | info " * Directory not found" 210 | resulttestjson "INFO" "Directory not found" 211 | currentScore=$((currentScore + 0)) 212 | fi 213 | } 214 | 215 | # 3.8 216 | check_3_8() { 217 | id_3_8="3.8" 218 | desc_3_8="Ensure that registry certificate file permissions are set to 444 or more restrictive" 219 | check_3_8="$id_3_8 - $desc_3_8" 220 | starttestjson "$id_3_8" "$desc_3_8" 221 | 222 | totalChecks=$((totalChecks + 1)) 223 | directory="/etc/docker/certs.d/" 224 | if [ -d "$directory" ]; then 225 | fail=0 226 | perms=$(find "$directory" -type f -name '*.crt') 227 | for p in $perms; do 228 | if [ "$(stat -c %a $p)" -ne 444 ] && [ "$(stat -c %a $p)" -ne 400 ]; then 229 | fail=1 230 | fi 231 | done 232 | if [ $fail -eq 1 ]; then 233 | warn "$check_3_8" 234 | warn " * Wrong permissions for $directory" 235 | resulttestjson "WARN" "Wrong permissions for $directory" 236 | currentScore=$((currentScore - 1)) 237 | else 238 | pass "$check_3_8" 239 | resulttestjson "PASS" 240 | currentScore=$((currentScore + 1)) 241 | fi 242 | else 243 | info "$check_3_8" 244 | info " * Directory not found" 245 | resulttestjson "INFO" "Directory not found" 246 | currentScore=$((currentScore + 0)) 247 | fi 248 | } 249 | 250 | # 3.9 251 | check_3_9() { 252 | id_3_9="3.9" 253 | desc_3_9="Ensure that TLS CA certificate file ownership is set to root:root" 254 | check_3_9="$id_3_9 - $desc_3_9" 255 | starttestjson "$id_3_9" "$desc_3_9" 256 | 257 | totalChecks=$((totalChecks + 1)) 258 | if ! [ -z $(get_docker_configuration_file_args 'tlscacert') ]; then 259 | tlscacert=$(get_docker_configuration_file_args 'tlscacert') 260 | else 261 | tlscacert=$(get_docker_effective_command_line_args '--tlscacert' | sed -n 's/.*tlscacert=\([^s]\)/\1/p' | sed 's/--/ --/g' | cut -d " " -f 1) 262 | fi 263 | if [ -f "$tlscacert" ]; then 264 | if [ "$(stat -c %u%g "$tlscacert")" -eq 00 ]; then 265 | pass "$check_3_9" 266 | resulttestjson "PASS" 267 | currentScore=$((currentScore + 1)) 268 | else 269 | warn "$check_3_9" 270 | warn " * Wrong ownership for $tlscacert" 271 | resulttestjson "WARN" "Wrong ownership for $tlscacert" 272 | currentScore=$((currentScore - 1)) 273 | fi 274 | else 275 | info "$check_3_9" 276 | info " * No TLS CA certificate found" 277 | resulttestjson "INFO" "No TLS CA certificate found" 278 | currentScore=$((currentScore + 0)) 279 | fi 280 | } 281 | 282 | # 3.10 283 | check_3_10() { 284 | id_3_10="3.10" 285 | desc_3_10="Ensure that TLS CA certificate file permissions are set to 444 or more restrictive" 286 | check_3_10="$id_3_10 - $desc_3_10" 287 | starttestjson "$id_3_10" "$desc_3_10" 288 | 289 | totalChecks=$((totalChecks + 1)) 290 | if ! [ -z $(get_docker_configuration_file_args 'tlscacert') ]; then 291 | tlscacert=$(get_docker_configuration_file_args 'tlscacert') 292 | else 293 | tlscacert=$(get_docker_effective_command_line_args '--tlscacert' | sed -n 's/.*tlscacert=\([^s]\)/\1/p' | sed 's/--/ --/g' | cut -d " " -f 1) 294 | fi 295 | if [ -f "$tlscacert" ]; then 296 | if [ "$(stat -c %a $tlscacert)" -eq 444 ] || [ "$(stat -c %a $tlscacert)" -eq 400 ]; then 297 | pass "$check_3_10" 298 | resulttestjson "PASS" 299 | currentScore=$((currentScore + 1)) 300 | else 301 | warn "$check_3_10" 302 | warn " * Wrong permissions for $tlscacert" 303 | resulttestjson "WARN" "Wrong permissions for $tlscacert" 304 | currentScore=$((currentScore - 1)) 305 | fi 306 | else 307 | info "$check_3_10" 308 | info " * No TLS CA certificate found" 309 | resulttestjson "INFO" "No TLS CA certificate found" 310 | currentScore=$((currentScore + 0)) 311 | fi 312 | } 313 | 314 | # 3.11 315 | check_3_11() { 316 | id_3_11="3.11" 317 | desc_3_11="Ensure that Docker server certificate file ownership is set to root:root" 318 | check_3_11="$id_3_11 - $desc_3_11" 319 | starttestjson "$id_3_11" "$desc_3_11" 320 | 321 | totalChecks=$((totalChecks + 1)) 322 | if ! [ -z $(get_docker_configuration_file_args 'tlscert') ]; then 323 | tlscert=$(get_docker_configuration_file_args 'tlscert') 324 | else 325 | tlscert=$(get_docker_effective_command_line_args '--tlscert' | sed -n 's/.*tlscert=\([^s]\)/\1/p' | sed 's/--/ --/g' | cut -d " " -f 1) 326 | fi 327 | if [ -f "$tlscert" ]; then 328 | if [ "$(stat -c %u%g "$tlscert")" -eq 00 ]; then 329 | pass "$check_3_11" 330 | resulttestjson "PASS" 331 | currentScore=$((currentScore + 1)) 332 | else 333 | warn "$check_3_11" 334 | warn " * Wrong ownership for $tlscert" 335 | resulttestjson "WARN" "Wrong ownership for $tlscert" 336 | currentScore=$((currentScore - 1)) 337 | fi 338 | else 339 | info "$check_3_11" 340 | info " * No TLS Server certificate found" 341 | resulttestjson "INFO" "No TLS Server certificate found" 342 | currentScore=$((currentScore + 0)) 343 | fi 344 | } 345 | 346 | # 3.12 347 | check_3_12() { 348 | id_3_12="3.12" 349 | desc_3_12="Ensure that Docker server certificate file permissions are set to 444 or more restrictive" 350 | check_3_12="$id_3_12 - $desc_3_12" 351 | starttestjson "$id_3_12" "$desc_3_12" 352 | 353 | totalChecks=$((totalChecks + 1)) 354 | if ! [ -z $(get_docker_configuration_file_args 'tlscert') ]; then 355 | tlscert=$(get_docker_configuration_file_args 'tlscert') 356 | else 357 | tlscert=$(get_docker_effective_command_line_args '--tlscert' | sed -n 's/.*tlscert=\([^s]\)/\1/p' | sed 's/--/ --/g' | cut -d " " -f 1) 358 | fi 359 | if [ -f "$tlscert" ]; then 360 | if [ "$(stat -c %a $tlscert)" -eq 444 ] || [ "$(stat -c %a $tlscert)" -eq 400 ]; then 361 | pass "$check_3_12" 362 | resulttestjson "PASS" 363 | currentScore=$((currentScore + 1)) 364 | else 365 | warn "$check_3_12" 366 | warn " * Wrong permissions for $tlscert" 367 | resulttestjson "WARN" "Wrong permissions for $tlscert" 368 | currentScore=$((currentScore - 1)) 369 | fi 370 | else 371 | info "$check_3_12" 372 | info " * No TLS Server certificate found" 373 | resulttestjson "INFO" "No TLS Server certificate found" 374 | currentScore=$((currentScore + 0)) 375 | fi 376 | } 377 | 378 | # 3.13 379 | check_3_13() { 380 | id_3_13="3.13" 381 | desc_3_13="Ensure that Docker server certificate key file ownership is set to root:root" 382 | check_3_13="$id_3_13 - $desc_3_13" 383 | starttestjson "$id_3_13" "$desc_3_13" 384 | 385 | totalChecks=$((totalChecks + 1)) 386 | if ! [ -z $(get_docker_configuration_file_args 'tlskey') ]; then 387 | tlskey=$(get_docker_configuration_file_args 'tlskey') 388 | else 389 | tlskey=$(get_docker_effective_command_line_args '--tlskey' | sed -n 's/.*tlskey=\([^s]\)/\1/p' | sed 's/--/ --/g' | cut -d " " -f 1) 390 | fi 391 | if [ -f "$tlskey" ]; then 392 | if [ "$(stat -c %u%g "$tlskey")" -eq 00 ]; then 393 | pass "$check_3_13" 394 | resulttestjson "PASS" 395 | currentScore=$((currentScore + 1)) 396 | else 397 | warn "$check_3_13" 398 | warn " * Wrong ownership for $tlskey" 399 | resulttestjson "WARN" "Wrong ownership for $tlskey" 400 | currentScore=$((currentScore - 1)) 401 | fi 402 | else 403 | info "$check_3_13" 404 | info " * No TLS Key found" 405 | resulttestjson "INFO" "No TLS Key found" 406 | currentScore=$((currentScore + 0)) 407 | fi 408 | } 409 | 410 | # 3.14 411 | check_3_14() { 412 | id_3_14="3.14" 413 | desc_3_14="Ensure that Docker server certificate key file permissions are set to 400" 414 | check_3_14="$id_3_14 - $desc_3_14" 415 | starttestjson "$id_3_14" "$desc_3_14" 416 | 417 | totalChecks=$((totalChecks + 1)) 418 | if ! [ -z $(get_docker_configuration_file_args 'tlskey') ]; then 419 | tlskey=$(get_docker_configuration_file_args 'tlskey') 420 | else 421 | tlskey=$(get_docker_effective_command_line_args '--tlskey' | sed -n 's/.*tlskey=\([^s]\)/\1/p' | sed 's/--/ --/g' | cut -d " " -f 1) 422 | fi 423 | if [ -f "$tlskey" ]; then 424 | if [ "$(stat -c %a $tlskey)" -eq 400 ]; then 425 | pass "$check_3_14" 426 | resulttestjson "PASS" 427 | currentScore=$((currentScore + 1)) 428 | else 429 | warn "$check_3_14" 430 | warn " * Wrong permissions for $tlskey" 431 | resulttestjson "WARN" "Wrong permissions for $tlskey" 432 | currentScore=$((currentScore - 1)) 433 | fi 434 | else 435 | info "$check_3_14" 436 | info " * No TLS Key found" 437 | resulttestjson "INFO" "No TLS Key found" 438 | currentScore=$((currentScore + 0)) 439 | fi 440 | } 441 | 442 | # 3.15 443 | check_3_15() { 444 | id_3_15="3.15" 445 | desc_3_15="Ensure that Docker socket file ownership is set to root:docker" 446 | check_3_15="$id_3_15 - $desc_3_15" 447 | starttestjson "$id_3_15" "$desc_3_15" 448 | 449 | totalChecks=$((totalChecks + 1)) 450 | file="/var/run/docker.sock" 451 | if [ -S "$file" ]; then 452 | if [ "$(stat -c %U:%G $file)" = 'root:docker' ]; then 453 | pass "$check_3_15" 454 | resulttestjson "PASS" 455 | currentScore=$((currentScore + 1)) 456 | else 457 | warn "$check_3_15" 458 | warn " * Wrong ownership for $file" 459 | resulttestjson "WARN" "Wrong ownership for $file" 460 | currentScore=$((currentScore - 1)) 461 | fi 462 | else 463 | info "$check_3_15" 464 | info " * File not found" 465 | resulttestjson "INFO" "File not found" 466 | currentScore=$((currentScore + 0)) 467 | fi 468 | } 469 | 470 | # 3.16 471 | check_3_16() { 472 | id_3_16="3.16" 473 | desc_3_16="Ensure that Docker socket file permissions are set to 660 or more restrictive" 474 | check_3_16="$id_3_16 - $desc_3_16" 475 | starttestjson "$id_3_16" "$desc_3_16" 476 | 477 | totalChecks=$((totalChecks + 1)) 478 | file="/var/run/docker.sock" 479 | if [ -S "$file" ]; then 480 | if [ "$(stat -c %a $file)" -eq 660 ] || [ "$(stat -c %a $file)" -eq 600 ]; then 481 | pass "$check_3_16" 482 | resulttestjson "PASS" 483 | currentScore=$((currentScore + 1)) 484 | else 485 | warn "$check_3_16" 486 | warn " * Wrong permissions for $file" 487 | resulttestjson "WARN" "Wrong permissions for $file" 488 | currentScore=$((currentScore - 1)) 489 | fi 490 | else 491 | info "$check_3_16" 492 | info " * File not found" 493 | resulttestjson "INFO" "File not found" 494 | currentScore=$((currentScore + 0)) 495 | fi 496 | } 497 | 498 | # 3.17 499 | check_3_17() { 500 | id_3_17="3.17" 501 | desc_3_17="Ensure that daemon.json file ownership is set to root:root" 502 | check_3_17="$id_3_17 - $desc_3_17" 503 | starttestjson "$id_3_17" "$desc_3_17" 504 | 505 | totalChecks=$((totalChecks + 1)) 506 | file="/etc/docker/daemon.json" 507 | if [ -f "$file" ]; then 508 | if [ "$(stat -c %U:%G $file)" = 'root:root' ]; then 509 | pass "$check_3_17" 510 | resulttestjson "PASS" 511 | currentScore=$((currentScore + 1)) 512 | else 513 | warn "$check_3_17" 514 | warn " * Wrong ownership for $file" 515 | resulttestjson "WARN" "Wrong ownership for $file" 516 | currentScore=$((currentScore - 1)) 517 | fi 518 | else 519 | info "$check_3_17" 520 | info " * File not found" 521 | resulttestjson "INFO" "File not found" 522 | currentScore=$((currentScore + 0)) 523 | fi 524 | } 525 | 526 | # 3.18 527 | check_3_18() { 528 | id_3_18="3.18" 529 | desc_3_18="Ensure that daemon.json file permissions are set to 644 or more restrictive" 530 | check_3_18="$id_3_18 - $desc_3_18" 531 | starttestjson "$id_3_18" "$desc_3_18" 532 | 533 | totalChecks=$((totalChecks + 1)) 534 | file="/etc/docker/daemon.json" 535 | if [ -f "$file" ]; then 536 | if [ "$(stat -c %a $file)" -eq 644 ] || [ "$(stat -c %a $file)" -eq 640 ] || [ "$(stat -c %a $file)" -eq 600 ]; then 537 | pass "$check_3_18" 538 | resulttestjson "PASS" 539 | currentScore=$((currentScore + 1)) 540 | else 541 | warn "$check_3_18" 542 | warn " * Wrong permissions for $file" 543 | resulttestjson "WARN" "Wrong permissions for $file" 544 | currentScore=$((currentScore - 1)) 545 | fi 546 | else 547 | info "$check_3_18" 548 | info " * File not found" 549 | resulttestjson "INFO" "File not found" 550 | currentScore=$((currentScore + 0)) 551 | fi 552 | } 553 | 554 | # 3.19 555 | check_3_19() { 556 | id_3_19="3.19" 557 | desc_3_19="Ensure that /etc/default/docker file ownership is set to root:root" 558 | check_3_19="$id_3_19 - $desc_3_19" 559 | starttestjson "$id_3_19" "$desc_3_19" 560 | 561 | totalChecks=$((totalChecks + 1)) 562 | file="/etc/default/docker" 563 | if [ -f "$file" ]; then 564 | if [ "$(stat -c %U:%G $file)" = 'root:root' ]; then 565 | pass "$check_3_19" 566 | resulttestjson "PASS" 567 | currentScore=$((currentScore + 1)) 568 | else 569 | warn "$check_3_19" 570 | warn " * Wrong ownership for $file" 571 | resulttestjson "WARN" "Wrong ownership for $file" 572 | currentScore=$((currentScore - 1)) 573 | fi 574 | else 575 | info "$check_3_19" 576 | info " * File not found" 577 | resulttestjson "INFO" "File not found" 578 | currentScore=$((currentScore + 0)) 579 | fi 580 | } 581 | 582 | # 3.20 583 | check_3_20() { 584 | id_3_20="3.20" 585 | desc_3_20="Ensure that /etc/default/docker file permissions are set to 644 or more restrictive" 586 | check_3_20="$id_3_20 - $desc_3_20" 587 | starttestjson "$id_3_20" "$desc_3_20" 588 | 589 | totalChecks=$((totalChecks + 1)) 590 | file="/etc/default/docker" 591 | if [ -f "$file" ]; then 592 | if [ "$(stat -c %a $file)" -eq 644 ] || [ "$(stat -c %a $file)" -eq 600 ]; then 593 | pass "$check_3_20" 594 | resulttestjson "PASS" 595 | currentScore=$((currentScore + 1)) 596 | else 597 | warn "$check_3_20" 598 | warn " * Wrong permissions for $file" 599 | resulttestjson "WARN" "Wrong permissions for $file" 600 | currentScore=$((currentScore - 1)) 601 | fi 602 | else 603 | info "$check_3_20" 604 | info " * File not found" 605 | resulttestjson "INFO" "File not found" 606 | currentScore=$((currentScore + 0)) 607 | fi 608 | } 609 | 610 | check_3_end() { 611 | endsectionjson 612 | } 613 | -------------------------------------------------------------------------------- /csf_client/tests/4_container_images.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -n "$imgList" ]; then 4 | pattern=$(echo "$imgList" | sed 's/,/ /g') 5 | for img in $pattern; do 6 | echo "Looking for image $img" 7 | sha256=$(docker image ls "$img" -q) 8 | if [ -z "$sha256" ]; then 9 | echo "Image $img not found. Exiting." 10 | exit 1 11 | fi 12 | images="$images $sha256 " 13 | done 14 | else 15 | images=$(docker images -q) 16 | fi 17 | 18 | check_4() { 19 | logit "\n" 20 | id_4="4" 21 | desc_4="Container Images and Build File" 22 | check_4="$id_4 - $desc_4" 23 | info "$check_4" 24 | startsectionjson "$id_4" "$desc_4" 25 | } 26 | 27 | # 4.1 28 | check_4_1() { 29 | id_4_1="4.1" 30 | desc_4_1="Ensure a user for the container has been created" 31 | check_4_1="$id_4_1 - $desc_4_1" 32 | starttestjson "$id_4_1" "$desc_4_1" 33 | 34 | totalChecks=$((totalChecks + 1)) 35 | 36 | # If container_users is empty, there are no running containers 37 | if [ -z "$containers" ]; then 38 | info "$check_4_1" 39 | info " * No containers running" 40 | resulttestjson "INFO" "No containers running" 41 | currentScore=$((currentScore + 0)) 42 | else 43 | # We have some containers running, set failure flag to 0. Check for Users. 44 | fail=0 45 | # Make the loop separator be a new-line in POSIX compliant fashion 46 | set -f; IFS=$' 47 | ' 48 | root_containers="" 49 | for c in $containers; do 50 | user=$(docker inspect --format 'User={{.Config.User}}' "$c") 51 | 52 | if [ "$user" = "User=0" ] || [ "$user" = "User=root" ] || [ "$user" = "User=" ] || [ "$user" = "User=[]" ] || [ "$user" = "User=" ]; then 53 | # If it's the first container, fail the test 54 | if [ $fail -eq 0 ]; then 55 | warn "$check_4_1" 56 | warn " * Running as root: $c" 57 | root_containers="$root_containers $c" 58 | fail=1 59 | else 60 | warn " * Running as root: $c" 61 | root_containers="$root_containers $c" 62 | fi 63 | fi 64 | done 65 | # We went through all the containers and found none running as root 66 | if [ $fail -eq 0 ]; then 67 | pass "$check_4_1" 68 | resulttestjson "PASS" 69 | currentScore=$((currentScore + 1)) 70 | else 71 | resulttestjson "WARN" "running as root" "$root_containers" 72 | currentScore=$((currentScore - 1)) 73 | fi 74 | fi 75 | # Make the loop separator go back to space 76 | set +f; unset IFS 77 | } 78 | 79 | # 4.2 80 | check_4_2() { 81 | id_4_2="4.2" 82 | desc_4_2="Ensure that containers use trusted base images" 83 | check_4_2="$id_4_2 - $desc_4_2" 84 | starttestjson "$id_4_2" "$desc_4_2" 85 | 86 | totalChecks=$((totalChecks + 1)) 87 | note "$check_4_2" 88 | resulttestjson "NOTE" 89 | currentScore=$((currentScore + 0)) 90 | } 91 | 92 | # 4.3 93 | check_4_3() { 94 | id_4_3="4.3" 95 | desc_4_3="Ensure unnecessary packages are not installed in the container" 96 | check_4_3="$id_4_3 - $desc_4_3" 97 | starttestjson "$id_4_3" "$desc_4_3" 98 | 99 | totalChecks=$((totalChecks + 1)) 100 | note "$check_4_3" 101 | resulttestjson "NOTE" 102 | currentScore=$((currentScore + 0)) 103 | } 104 | 105 | # 4.4 106 | check_4_4() { 107 | id_4_4="4.4" 108 | desc_4_4="Ensure images are scanned and rebuilt to include security patches" 109 | check_4_4="$id_4_4 - $desc_4_4" 110 | starttestjson "$id_4_4" "$desc_4_4" 111 | 112 | totalChecks=$((totalChecks + 1)) 113 | note "$check_4_4" 114 | resulttestjson "NOTE" 115 | currentScore=$((currentScore + 0)) 116 | } 117 | 118 | # 4.5 119 | check_4_5() { 120 | id_4_5="4.5" 121 | desc_4_5="Ensure Content trust for Docker is Enabled" 122 | check_4_5="$id_4_5 - $desc_4_5" 123 | starttestjson "$id_4_5" "$desc_4_5" 124 | 125 | totalChecks=$((totalChecks + 1)) 126 | if [ "x$DOCKER_CONTENT_TRUST" = "x1" ]; then 127 | pass "$check_4_5" 128 | resulttestjson "PASS" 129 | currentScore=$((currentScore + 1)) 130 | else 131 | warn "$check_4_5" 132 | resulttestjson "WARN" 133 | currentScore=$((currentScore - 1)) 134 | fi 135 | } 136 | 137 | # 4.6 138 | check_4_6() { 139 | id_4_6="4.6" 140 | desc_4_6="Ensure HEALTHCHECK instructions have been added to the container image" 141 | check_4_6="$id_4_6 - $desc_4_6" 142 | starttestjson "$id_4_6" "$desc_4_6" 143 | 144 | totalChecks=$((totalChecks + 1)) 145 | fail=0 146 | no_health_images="" 147 | for img in $images; do 148 | if docker inspect --format='{{.Config.Healthcheck}}' "$img" 2>/dev/null | grep -e "" >/dev/null 2>&1; then 149 | if [ $fail -eq 0 ]; then 150 | fail=1 151 | warn "$check_4_6" 152 | fi 153 | imgName=$(docker inspect --format='{{.RepoTags}}' "$img" 2>/dev/null) 154 | if ! [ "$imgName" = '[]' ]; then 155 | warn " * No Healthcheck found: $imgName" 156 | no_health_images="$no_health_images $imgName" 157 | fi 158 | fi 159 | done 160 | if [ $fail -eq 0 ]; then 161 | pass "$check_4_6" 162 | resulttestjson "PASS" 163 | currentScore=$((currentScore + 1)) 164 | else 165 | resulttestjson "WARN" "Images w/o HEALTHCHECK" "$no_health_images" 166 | currentScore=$((currentScore - 1)) 167 | fi 168 | } 169 | 170 | # 4.7 171 | check_4_7() { 172 | id_4_7="4.7" 173 | desc_4_7="Ensure update instructions are not use alone in the Dockerfile" 174 | check_4_7="$id_4_7 - $desc_4_7" 175 | starttestjson "$id_4_7" "$desc_4_7" 176 | 177 | totalChecks=$((totalChecks + 1)) 178 | fail=0 179 | update_images="" 180 | for img in $images; do 181 | if docker history "$img" 2>/dev/null | grep -e "update" >/dev/null 2>&1; then 182 | if [ $fail -eq 0 ]; then 183 | fail=1 184 | info "$check_4_7" 185 | fi 186 | imgName=$(docker inspect --format='{{.RepoTags}}' "$img" 2>/dev/null) 187 | if ! [ "$imgName" = '[]' ]; then 188 | info " * Update instruction found: $imgName" 189 | update_images="$update_images $imgName" 190 | fi 191 | fi 192 | done 193 | if [ $fail -eq 0 ]; then 194 | pass "$check_4_7" 195 | resulttestjson "PASS" 196 | currentScore=$((currentScore + 0)) 197 | else 198 | resulttestjson "INFO" "Update instructions found" "$update_images" 199 | currentScore=$((currentScore + 0)) 200 | fi 201 | } 202 | 203 | # 4.8 204 | check_4_8() { 205 | id_4_8="4.8" 206 | desc_4_8="Ensure setuid and setgid permissions are removed in the images" 207 | check_4_8="$id_4_8 - $desc_4_8" 208 | starttestjson "$id_4_8" "$desc_4_8" 209 | 210 | totalChecks=$((totalChecks + 1)) 211 | note "$check_4_8" 212 | resulttestjson "NOTE" 213 | currentScore=$((currentScore + 0)) 214 | } 215 | 216 | # 4.9 217 | check_4_9() { 218 | id_4_9="4.9" 219 | desc_4_9="Ensure COPY is used instead of ADD in Dockerfile" 220 | check_4_9="$id_4_9 - $desc_4_9" 221 | starttestjson "$id_4_9" "$desc_4_9" 222 | 223 | totalChecks=$((totalChecks + 1)) 224 | fail=0 225 | add_images="" 226 | for img in $images; do 227 | docker history "$img" 2> /dev/null | grep 'ADD' >/dev/null 2>&1 228 | if [ $? -eq 0 ]; then 229 | if [ $fail -eq 0 ]; then 230 | fail=1 231 | info "$check_4_9" 232 | fi 233 | imgName=$(docker inspect --format='{{.RepoTags}}' "$img" 2>/dev/null) 234 | if ! [ "$imgName" = '[]' ]; then 235 | info " * ADD in image history: $imgName" 236 | add_images="$add_images $imgName" 237 | fi 238 | currentScore=$((currentScore + 0)) 239 | fi 240 | done 241 | if [ $fail -eq 0 ]; then 242 | pass "$check_4_9" 243 | resulttestjson "PASS" 244 | currentScore=$((currentScore + 1)) 245 | else 246 | resulttestjson "INFO" "Images using ADD" "$add_images" 247 | fi 248 | } 249 | 250 | # 4.10 251 | check_4_10() { 252 | id_4_10="4.10" 253 | desc_4_10="Ensure secrets are not stored in Dockerfiles" 254 | check_4_10="$id_4_10 - $desc_4_10" 255 | starttestjson "$id_4_10" "$desc_4_10" 256 | 257 | totalChecks=$((totalChecks + 1)) 258 | note "$check_4_10" 259 | resulttestjson "NOTE" 260 | currentScore=$((currentScore + 0)) 261 | } 262 | 263 | # 4.11 264 | check_4_11() { 265 | id_4_11="4.11" 266 | desc_4_11="Ensure verified packages are only Installed" 267 | check_4_11="$id_4_11 - $desc_4_11" 268 | starttestjson "$id_4_11" "$desc_4_11" 269 | 270 | totalChecks=$((totalChecks + 1)) 271 | note "$check_4_11" 272 | resulttestjson "NOTE" 273 | currentScore=$((currentScore + 0)) 274 | } 275 | 276 | check_4_end() { 277 | endsectionjson 278 | } 279 | -------------------------------------------------------------------------------- /csf_client/tests/6_docker_security_operations.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | check_6() { 4 | logit "\n" 5 | id_6="6" 6 | desc_6="Docker Security Operations" 7 | check_6="$id_6 - $desc_6" 8 | info "$check_6" 9 | startsectionjson "$id_6" "$desc_6" 10 | } 11 | 12 | # 6.1 13 | check_6_1() { 14 | id_6_1="6.1" 15 | desc_6_1="Avoid image sprawl" 16 | check_6_1="$id_6_1 - $desc_6_1" 17 | starttestjson "$id_6_1" "$desc_6_1" 18 | 19 | totalChecks=$((totalChecks + 1)) 20 | images=$(docker images -q | sort -u | wc -l | awk '{print $1}') 21 | active_images=0 22 | 23 | for c in $(docker inspect --format "{{.Image}}" $(docker ps -qa) 2>/dev/null); do 24 | if docker images --no-trunc -a | grep "$c" > /dev/null ; then 25 | active_images=$(( active_images += 1 )) 26 | fi 27 | done 28 | 29 | info "$check_6_1" 30 | info " * There are currently: $images images" 31 | 32 | if [ "$active_images" -lt "$((images / 2))" ]; then 33 | info " * Only $active_images out of $images are in use" 34 | fi 35 | resulttestjson "INFO" "$active_images active/$images in use" 36 | currentScore=$((currentScore + 0)) 37 | } 38 | 39 | # 6.2 40 | check_6_2() { 41 | id_6_2="6.2" 42 | desc_6_2="Avoid container sprawl" 43 | check_6_2="$id_6_2 - $desc_6_2" 44 | starttestjson "$id_6_2" "$desc_6_2" 45 | 46 | totalChecks=$((totalChecks + 1)) 47 | total_containers=$(docker info 2>/dev/null | grep "Containers" | awk '{print $2}') 48 | running_containers=$(docker ps -q | wc -l | awk '{print $1}') 49 | diff="$((total_containers - running_containers))" 50 | if [ "$diff" -gt 25 ]; then 51 | info "$check_6_2" 52 | info " * There are currently a total of $total_containers containers, with only $running_containers of them currently running" 53 | resulttestjson "INFO" "$total_containers total/$running_containers running" 54 | else 55 | info "$check_6_2" 56 | info " * There are currently a total of $total_containers containers, with $running_containers of them currently running" 57 | resulttestjson "INFO" "$total_containers total/$running_containers running" 58 | fi 59 | currentScore=$((currentScore + 0)) 60 | } 61 | 62 | check_6_end() { 63 | endsectionjson 64 | } 65 | -------------------------------------------------------------------------------- /csf_client/tests/7_docker_swarm_configuration.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | check_7() { 4 | logit "\n" 5 | id_7="7" 6 | desc_7="Docker Swarm Configuration" 7 | check_7="$id_7 - $desc_7" 8 | info "$check_7" 9 | startsectionjson "$id_7" "$desc_7" 10 | } 11 | 12 | # 7.1 13 | check_7_1() { 14 | id_7_1="7.1" 15 | desc_7_1="Ensure swarm mode is not Enabled, if not needed" 16 | check_7_1="$id_7_1 - $desc_7_1" 17 | starttestjson "$id_7_1" "$desc_7_1" 18 | 19 | totalChecks=$((totalChecks + 1)) 20 | if docker info 2>/dev/null | grep -e "Swarm:*\sinactive\s*" >/dev/null 2>&1; then 21 | pass "$check_7_1" 22 | resulttestjson "PASS" 23 | currentScore=$((currentScore + 1)) 24 | else 25 | warn "$check_7_1" 26 | resulttestjson "WARN" 27 | currentScore=$((currentScore - 1)) 28 | fi 29 | } 30 | 31 | # 7.2 32 | check_7_2() { 33 | id_7_2="7.2" 34 | desc_7_2="Ensure the minimum number of manager nodes have been created in a swarm" 35 | check_7_2="$id_7_2 - $desc_7_2" 36 | starttestjson "$id_7_2" "$desc_7_2" 37 | 38 | totalChecks=$((totalChecks + 1)) 39 | if docker info 2>/dev/null | grep -e "Swarm:*\sactive\s*" >/dev/null 2>&1; then 40 | managernodes=$(docker node ls | grep -c "Leader") 41 | if [ "$managernodes" -le 1 ]; then 42 | pass "$check_7_2" 43 | resulttestjson "PASS" 44 | currentScore=$((currentScore + 1)) 45 | else 46 | warn "$check_7_2" 47 | resulttestjson "WARN" 48 | currentScore=$((currentScore - 1)) 49 | fi 50 | else 51 | pass "$check_7_2 (Swarm mode not enabled)" 52 | resulttestjson "PASS" 53 | currentScore=$((currentScore + 1)) 54 | fi 55 | } 56 | 57 | # 7.3 58 | check_7_3() { 59 | id_7_3="7.3" 60 | desc_7_3="Ensure swarm services are binded to a specific host interface" 61 | check_7_3="$id_7_3 - $desc_7_3" 62 | starttestjson "$id_7_3" "$desc_7_3" 63 | 64 | totalChecks=$((totalChecks + 1)) 65 | if docker info 2>/dev/null | grep -e "Swarm:*\sactive\s*" >/dev/null 2>&1; then 66 | ss -lnt | grep -e '\[::]:2377 ' -e ':::2377' -e '*:2377 ' -e ' 0\.0\.0\.0:2377 ' >/dev/null 2>&1 67 | if [ $? -eq 1 ]; then 68 | pass "$check_7_3" 69 | resulttestjson "PASS" 70 | currentScore=$((currentScore + 1)) 71 | else 72 | warn "$check_7_3" 73 | resulttestjson "WARN" 74 | currentScore=$((currentScore - 1)) 75 | fi 76 | else 77 | pass "$check_7_3 (Swarm mode not enabled)" 78 | resulttestjson "PASS" 79 | currentScore=$((currentScore + 1)) 80 | fi 81 | } 82 | 83 | # 7.4 84 | check_7_4() { 85 | id_7_4="7.4" 86 | desc_7_4="Ensure data exchanged between containers are encrypted on different nodes on the overlay network" 87 | check_7_4="$id_7_4 - $desc_7_4" 88 | starttestjson "$id_7_4" "$desc_7_4" 89 | 90 | totalChecks=$((totalChecks + 1)) 91 | fail=0 92 | unencrypted_networks="" 93 | for encnet in $(docker network ls --filter driver=overlay --quiet); do 94 | if docker network inspect --format '{{.Name}} {{ .Options }}' "$encnet" | \ 95 | grep -v 'encrypted:' 2>/dev/null 1>&2; then 96 | # If it's the first container, fail the test 97 | if [ $fail -eq 0 ]; then 98 | warn "$check_7_4" 99 | fail=1 100 | fi 101 | warn " * Unencrypted overlay network: $(docker network inspect --format '{{ .Name }} ({{ .Scope }})' "$encnet")" 102 | unencrypted_networks="$unencrypted_networks $(docker network inspect --format '{{ .Name }} ({{ .Scope }})' "$encnet")" 103 | fi 104 | done 105 | # We went through all the networks and found none that are unencrypted 106 | if [ $fail -eq 0 ]; then 107 | pass "$check_7_4" 108 | resulttestjson "PASS" 109 | currentScore=$((currentScore + 1)) 110 | else 111 | resulttestjson "WARN" "Unencrypted overlay networks:" "$unencrypted_networks" 112 | currentScore=$((currentScore - 1)) 113 | fi 114 | } 115 | 116 | # 7.5 117 | check_7_5() { 118 | id_7_5="7.5" 119 | desc_7_5="Ensure Docker's secret management commands are used for managing secrets in a Swarm cluster" 120 | check_7_5="$id_7_5 - $desc_7_5" 121 | starttestjson "$id_7_5" "$desc_7_5" 122 | 123 | totalChecks=$((totalChecks + 1)) 124 | if docker info 2>/dev/null | grep -e "Swarm:\s*active\s*" >/dev/null 2>&1; then 125 | if [ "$(docker secret ls -q | wc -l)" -ge 1 ]; then 126 | pass "$check_7_5" 127 | resulttestjson "PASS" 128 | currentScore=$((currentScore + 1)) 129 | else 130 | info "$check_7_5" 131 | resulttestjson "INFO" 132 | currentScore=$((currentScore + 0)) 133 | fi 134 | else 135 | pass "$check_7_5 (Swarm mode not enabled)" 136 | resulttestjson "PASS" 137 | currentScore=$((currentScore + 1)) 138 | fi 139 | } 140 | 141 | # 7.6 142 | check_7_6() { 143 | id_7_6="7.6" 144 | desc_7_6="Ensure swarm manager is run in auto-lock mode" 145 | check_7_6="$id_7_6 - $desc_7_6" 146 | starttestjson "$id_7_6" "$desc_7_6" 147 | 148 | totalChecks=$((totalChecks + 1)) 149 | if docker info 2>/dev/null | grep -e "Swarm:\s*active\s*" >/dev/null 2>&1; then 150 | if ! docker swarm unlock-key 2>/dev/null | grep 'SWMKEY' 2>/dev/null 1>&2; then 151 | warn "$check_7_6" 152 | resulttestjson "WARN" 153 | currentScore=$((currentScore - 1)) 154 | else 155 | pass "$check_7_6" 156 | resulttestjson "PASS" 157 | currentScore=$((currentScore + 1)) 158 | fi 159 | else 160 | pass "$check_7_6 (Swarm mode not enabled)" 161 | resulttestjson "PASS" 162 | currentScore=$((currentScore + 1)) 163 | fi 164 | } 165 | 166 | # 7.7 167 | check_7_7() { 168 | id_7_7="7.7" 169 | desc_7_7="Ensure swarm manager auto-lock key is rotated periodically" 170 | check_7_7="$id_7_7 - $desc_7_7" 171 | starttestjson "$id_7_7" "$desc_7_7" 172 | 173 | totalChecks=$((totalChecks + 1)) 174 | if docker info 2>/dev/null | grep -e "Swarm:\s*active\s*" >/dev/null 2>&1; then 175 | note "$check_7_7" 176 | resulttestjson "NOTE" 177 | currentScore=$((currentScore + 0)) 178 | else 179 | pass "$check_7_7 (Swarm mode not enabled)" 180 | resulttestjson "PASS" 181 | currentScore=$((currentScore + 1)) 182 | fi 183 | } 184 | 185 | # 7.8 186 | check_7_8() { 187 | id_7_8="7.8" 188 | desc_7_8="Ensure node certificates are rotated as appropriate" 189 | check_7_8="$id_7_8 - $desc_7_8" 190 | starttestjson "$id_7_8" "$desc_7_8" 191 | 192 | totalChecks=$((totalChecks + 1)) 193 | if docker info 2>/dev/null | grep -e "Swarm:\s*active\s*" >/dev/null 2>&1; then 194 | if docker info 2>/dev/null | grep "Expiry Duration: 2 days"; then 195 | pass "$check_7_8" 196 | resulttestjson "PASS" 197 | currentScore=$((currentScore + 1)) 198 | else 199 | info "$check_7_8" 200 | resulttestjson "INFO" 201 | currentScore=$((currentScore + 0)) 202 | fi 203 | else 204 | pass "$check_7_8 (Swarm mode not enabled)" 205 | resulttestjson "PASS" 206 | currentScore=$((currentScore + 1)) 207 | fi 208 | } 209 | 210 | # 7.9 211 | check_7_9() { 212 | id_7_9="7.9" 213 | desc_7_9="Ensure CA certificates are rotated as appropriate" 214 | check_7_9="$id_7_9 - $desc_7_9" 215 | starttestjson "$id_7_9" "$desc_7_9" 216 | 217 | totalChecks=$((totalChecks + 1)) 218 | if docker info 2>/dev/null | grep -e "Swarm:\s*active\s*" >/dev/null 2>&1; then 219 | info "$check_7_9" 220 | resulttestjson "INFO" 221 | currentScore=$((currentScore + 0)) 222 | else 223 | pass "$check_7_9 (Swarm mode not enabled)" 224 | resulttestjson "PASS" 225 | currentScore=$((currentScore + 1)) 226 | fi 227 | } 228 | 229 | # 7.10 230 | check_7_10() { 231 | id_7_10="7.10" 232 | desc_7_10="Ensure management plane traffic has been separated from data plane traffic" 233 | check_7_10="$id_7_10 - $desc_7_10" 234 | starttestjson "$id_7_10" "$desc_7_10" 235 | 236 | totalChecks=$((totalChecks + 1)) 237 | if docker info 2>/dev/null | grep -e "Swarm:\s*active\s*" >/dev/null 2>&1; then 238 | info "$check_7_10" 239 | resulttestjson "INFO" 240 | currentScore=$((currentScore + 0)) 241 | else 242 | pass "$check_7_10 (Swarm mode not enabled)" 243 | resulttestjson "PASS" 244 | currentScore=$((currentScore + 1)) 245 | fi 246 | } 247 | 248 | check_7_end() { 249 | endsectionjson 250 | } 251 | -------------------------------------------------------------------------------- /csf_client/tests/99_community_checks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | check_c() { 3 | logit "\n" 4 | id_99="99" 5 | desc_99="Community contributed checks" 6 | check_99="$id_99 - $desc_99" 7 | info "$check_99" 8 | startsectionjson "$id_99" "$desc_99" 9 | } 10 | 11 | # check_c_1 12 | check_c_1() { 13 | check_c_1="C.1 - This is a example check" 14 | totalChecks=$((totalChecks + 1)) 15 | if docker info --format='{{ .Architecture }}' | grep 'x86_64' 2>/dev/null 1>&2; then 16 | pass "$check_c_1" 17 | resulttestjson "PASS" 18 | else 19 | warn "$check_c_1" 20 | resulttestjson "WARN" 21 | fi 22 | } 23 | 24 | check_c_end() { 25 | endsectionjson 26 | } 27 | -------------------------------------------------------------------------------- /csf_server/.dockerignore: -------------------------------------------------------------------------------- 1 | db.sqlite3 2 | venv/ 3 | csfapi/migrations/ 4 | db/ 5 | -------------------------------------------------------------------------------- /csf_server/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/* 2 | 3 | # Byte-compiled / optimized / DLL files 4 | __pycache__/ 5 | *.py[cod] 6 | *$py.class 7 | 8 | # C extensions 9 | *.so 10 | 11 | # Distribution / packaging 12 | .Python 13 | build/ 14 | develop-eggs/ 15 | dist/ 16 | downloads/ 17 | eggs/ 18 | .eggs/ 19 | lib/ 20 | lib64/ 21 | parts/ 22 | sdist/ 23 | var/ 24 | wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | .hypothesis/ 50 | .pytest_cache/ 51 | 52 | # Translations 53 | *.mo 54 | *.pot 55 | 56 | # Django stuff: 57 | *.log 58 | local_settings.py 59 | db.sqlite3 60 | 61 | # Flask stuff: 62 | instance/ 63 | .webassets-cache 64 | 65 | # Scrapy stuff: 66 | .scrapy 67 | 68 | # Sphinx documentation 69 | docs/_build/ 70 | 71 | # PyBuilder 72 | target/ 73 | 74 | # Jupyter Notebook 75 | .ipynb_checkpoints 76 | 77 | # pyenv 78 | .python-version 79 | 80 | # celery beat schedule file 81 | celerybeat-schedule 82 | 83 | # SageMath parsed files 84 | *.sage.py 85 | 86 | # Environments 87 | .env 88 | .venv 89 | env/ 90 | venv/ 91 | ENV/ 92 | env.bak/ 93 | venv.bak/ 94 | 95 | # Spyder project settings 96 | .spyderproject 97 | .spyproject 98 | 99 | # Rope project settings 100 | .ropeproject 101 | 102 | # mkdocs documentation 103 | /site 104 | 105 | # mypy 106 | .mypy_cache/ 107 | 108 | #Django 109 | */migrations/* 110 | db/* 111 | -------------------------------------------------------------------------------- /csf_server/Dockerfile: -------------------------------------------------------------------------------- 1 | #Base image 2 | FROM python:3.7.4-alpine 3 | 4 | LABEL \ 5 | name="csf-server" \ 6 | version="1.0Beta" \ 7 | github="https://github.com/armourbird/csf" 8 | 9 | #Add CSF master 10 | WORKDIR /root/CSF 11 | COPY . /root/CSF 12 | 13 | #Install python packages 14 | RUN pip install -r requirements.txt 15 | 16 | EXPOSE 8000 17 | CMD ["/bin/sh", "./start.sh"] -------------------------------------------------------------------------------- /csf_server/csf_server/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armourbird/csf/6bdb6567f21c9b725204c300cd464978e01a6ae4/csf_server/csf_server/__init__.py -------------------------------------------------------------------------------- /csf_server/csf_server/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for csf_server project. 3 | 4 | Generated by 'django-admin startproject' using Django 2.1.7. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.1/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/2.1/ref/settings/ 11 | """ 12 | 13 | import os 14 | from django.core.management.utils import get_random_secret_key 15 | 16 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) 17 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 18 | 19 | 20 | # Quick-start development settings - unsuitable for production 21 | # See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/ 22 | 23 | # SECURITY WARNING: keep the secret key used in production secret! 24 | SECRET_KEY = get_random_secret_key() 25 | 26 | # SECURITY WARNING: don't run with debug turned on in production! 27 | DEBUG = True 28 | 29 | ALLOWED_HOSTS = ['*'] 30 | 31 | 32 | # Application definition 33 | 34 | INSTALLED_APPS = [ 35 | 'django.contrib.admin', 36 | 'django.contrib.auth', 37 | 'django.contrib.contenttypes', 38 | 'django.contrib.sessions', 39 | 'django.contrib.messages', 40 | 'django.contrib.staticfiles', 41 | 'csfapi.apps.CsfapiConfig', 42 | 'rest_framework', 43 | 'corsheaders', 44 | 'gunicorn' 45 | ] 46 | 47 | MIDDLEWARE = [ 48 | 'django.middleware.security.SecurityMiddleware', 49 | 'django.contrib.sessions.middleware.SessionMiddleware', 50 | 'django.middleware.common.CommonMiddleware', 51 | 'django.middleware.csrf.CsrfViewMiddleware', 52 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 53 | 'django.contrib.messages.middleware.MessageMiddleware', 54 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 55 | 'corsheaders.middleware.CorsMiddleware', 56 | ] 57 | 58 | CORS_ORIGIN_ALLOW_ALL = True 59 | ROOT_URLCONF = 'csf_server.urls' 60 | 61 | TEMPLATES = [ 62 | { 63 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 64 | 'DIRS': ['templates'], 65 | 'APP_DIRS': True, 66 | 'OPTIONS': { 67 | 'context_processors': [ 68 | 'django.template.context_processors.debug', 69 | 'django.template.context_processors.request', 70 | 'django.contrib.auth.context_processors.auth', 71 | 'django.contrib.messages.context_processors.messages', 72 | ], 73 | }, 74 | }, 75 | ] 76 | 77 | WSGI_APPLICATION = 'csf_server.wsgi.application' 78 | 79 | 80 | # Database 81 | # https://docs.djangoproject.com/en/2.1/ref/settings/#databases 82 | 83 | DATABASES = { 84 | 'default': { 85 | 'ENGINE': 'django.db.backends.sqlite3', 86 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 87 | } 88 | } 89 | 90 | 91 | # Password validation 92 | # https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators 93 | 94 | AUTH_PASSWORD_VALIDATORS = [ 95 | { 96 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 97 | }, 98 | { 99 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 100 | }, 101 | { 102 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 103 | }, 104 | { 105 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 106 | }, 107 | ] 108 | 109 | 110 | # Internationalization 111 | # https://docs.djangoproject.com/en/2.1/topics/i18n/ 112 | 113 | LANGUAGE_CODE = 'en-us' 114 | 115 | TIME_ZONE = 'UTC' 116 | 117 | USE_I18N = True 118 | 119 | USE_L10N = True 120 | 121 | USE_TZ = True 122 | 123 | 124 | # Static files (CSS, JavaScript, Images) 125 | # https://docs.djangoproject.com/en/2.1/howto/static-files/ 126 | 127 | STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')] 128 | STATIC_URL = '/static/' 129 | STATIC_ROOT = '/static/' -------------------------------------------------------------------------------- /csf_server/csf_server/urls.py: -------------------------------------------------------------------------------- 1 | """csf_server URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/2.1/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: path('', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.urls import include, path 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15 | """ 16 | from django.contrib import admin 17 | from django.urls import path, include 18 | from django.views.generic import TemplateView 19 | 20 | urlpatterns = [ 21 | path('admin/', admin.site.urls), 22 | path(r'api/', include('csfapi.urls'), name="csf-api"), 23 | path('dashboard/', TemplateView.as_view(template_name='screens/dashboard.html')), 24 | path('view-all-issues/', TemplateView.as_view(template_name='screens/view-all-issues.html')), 25 | path('view-issues-client/', TemplateView.as_view(template_name='screens/view-issues-client.html')), 26 | path('view-issues-clientgroup/', TemplateView.as_view(template_name='screens/view-issues-clientgroup.html')), 27 | path('update-issue/', TemplateView.as_view(template_name='screens/update-issue.html')), 28 | path('view-clients/', TemplateView.as_view(template_name='screens/view-clients.html')), 29 | path('update-client/', TemplateView.as_view(template_name='screens/update-client.html')), 30 | path('add-clientgroup/', TemplateView.as_view(template_name='screens/add-clientgroup.html')), 31 | path('view-clientgroup/', TemplateView.as_view(template_name='screens/view-clientgroup.html')), 32 | path('update-clientgroup/', TemplateView.as_view(template_name='screens/update-clientgroup.html')), 33 | path('view-issue/', TemplateView.as_view(template_name='screens/view-issue.html')) 34 | ] 35 | -------------------------------------------------------------------------------- /csf_server/csf_server/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for csf_server project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'csf_server.settings') 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /csf_server/csfapi/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armourbird/csf/6bdb6567f21c9b725204c300cd464978e01a6ae4/csf_server/csfapi/__init__.py -------------------------------------------------------------------------------- /csf_server/csfapi/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | from . models import Issues, Users, Clients, ClientGroups 4 | 5 | # Register your models here. 6 | 7 | admin.site.register(Issues) 8 | admin.site.register(Users) 9 | admin.site.register(Clients) 10 | admin.site.register(ClientGroups) 11 | 12 | -------------------------------------------------------------------------------- /csf_server/csfapi/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class CsfapiConfig(AppConfig): 5 | name = 'csfapi' 6 | -------------------------------------------------------------------------------- /csf_server/csfapi/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | import uuid 3 | from datetime import datetime 4 | from django.utils import timezone 5 | # Create your models here. 6 | 7 | 8 | class Issues (models.Model): 9 | issueId = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False, unique=True) 10 | checkId = models.CharField(max_length=10, blank=True, default='') 11 | checkDesc = models.CharField(max_length=100, blank=True, default='') 12 | severity = models.CharField(max_length=1, blank=True, default='') 13 | issueClientId = models.UUIDField() 14 | fixStatus = models.CharField(max_length=1, blank=True, default='') 15 | creationDate = models.DateTimeField(default=timezone.now, blank=True) 16 | checkComment = models.CharField(max_length=1000, blank=True, default='') 17 | 18 | 19 | class Users (models.Model): 20 | userId = models.CharField(max_length=100, blank=True, default='') 21 | userName = models.CharField(max_length=100, blank=True, default='') 22 | userPassword = models.CharField(max_length=100, blank=True, default='') 23 | fullName = models.CharField(max_length=100, blank=True, default='') 24 | accessLevel = models.CharField(max_length=100, blank=True, default='') 25 | creationDate = models.CharField(max_length=100, blank=True, default='') 26 | userPref = models.CharField(max_length=100, blank=True, default='') 27 | 28 | 29 | class Clients (models.Model): 30 | clientId = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False, unique=True) 31 | clientIP = models.CharField(max_length=100, blank=True, default='') 32 | clientName = models.CharField(max_length=100, blank=True, default='') 33 | clientPrefs = models.CharField(max_length=100, blank=True, default='') 34 | clientGroupID = models.CharField(max_length=100, blank=True, default='') 35 | 36 | 37 | class ClientGroups (models.Model): 38 | groupID = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False, unique=True) 39 | groupName = models.CharField(max_length=100, blank=True, default='') 40 | groupPrefs = models.CharField(max_length=100, blank=True, default='') -------------------------------------------------------------------------------- /csf_server/csfapi/serializers.py: -------------------------------------------------------------------------------- 1 | from rest_framework import serializers 2 | from csfapi.models import Issues, Users, Clients, ClientGroups 3 | 4 | 5 | class IssuesSerializer(serializers.ModelSerializer): 6 | 7 | class Meta: 8 | model = Issues 9 | fields = ('issueId', 'checkId', 'checkDesc', 'severity', 'issueClientId', 'fixStatus', 'creationDate', 'checkComment') 10 | 11 | 12 | class UsersSerializer(serializers.ModelSerializer): 13 | 14 | class Meta: 15 | model = Users 16 | fields = ('userId', 'userName', 'userPassword', 'fullName', 'accessLevel', 'creationDate', 'userPref') 17 | 18 | 19 | class ClientsSerializer(serializers.ModelSerializer): 20 | 21 | class Meta: 22 | model = Clients 23 | fields = ('clientId', 'clientIP', 'clientName', 'clientPrefs', 'clientGroupID') 24 | 25 | 26 | class ClientGroupsSerializer(serializers.ModelSerializer): 27 | 28 | class Meta: 29 | model = ClientGroups 30 | fields = ('groupID', 'groupName', 'groupPrefs') 31 | -------------------------------------------------------------------------------- /csf_server/csfapi/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /csf_server/csfapi/urls.py: -------------------------------------------------------------------------------- 1 | from django.urls import path, include 2 | from csfapi.views import issues_view, issues_view_details, users_view, clients_view, clients_view_details, clientgroups_view, clientgroups_view_details, userlogin_view 3 | 4 | urlpatterns = [ 5 | path(r'issues/', issues_view, name='issues_view'), 6 | path(r'issues/', issues_view_details, name='issues_view_details'), 7 | path(r'users/', users_view, name='users_view'), 8 | path(r'clients/', clients_view, name='client_view'), 9 | path(r'clients/', clients_view_details, name='clients_view_details'), 10 | path(r'clientgroups/', clientgroups_view, name='clientgroups_view'), 11 | path(r'clientgroups/', clientgroups_view_details, name='clientgroups_view_details'), 12 | path(r'userlogin/', userlogin_view, name='userlogin_view'), 13 | ] 14 | -------------------------------------------------------------------------------- /csf_server/csfapi/views.py: -------------------------------------------------------------------------------- 1 | from rest_framework import status 2 | import json 3 | import base64 4 | from django.http import HttpRequest 5 | from rest_framework.decorators import api_view 6 | from rest_framework.response import Response 7 | from csfapi.models import Issues, Users, Clients, ClientGroups 8 | from csfapi.serializers import IssuesSerializer, UsersSerializer, ClientsSerializer, ClientGroupsSerializer 9 | 10 | 11 | @api_view(['GET', 'POST']) 12 | def issues_view(request): 13 | # Functionality 1: To view all issues 14 | # Functionality 2: To add new issue 15 | if request.method == 'GET': 16 | issues = Issues.objects.all() 17 | serializer = IssuesSerializer(issues, many=True) 18 | return Response(serializer.data) 19 | 20 | if request.method == 'POST': 21 | 22 | decoded_data = base64.b64decode(request.POST.get('data')) 23 | decoded_obj = json.loads(decoded_data) 24 | 25 | with open('static/checks.json') as checks_json: 26 | checks_data = json.load(checks_json) 27 | 28 | #Save Client IP in Clients model if not already exists 29 | try: 30 | issue_client = Clients.objects.get(clientIP=request.META.get('REMOTE_ADDR')) 31 | except: 32 | print("DEBUG LOG: Client not exists: %s" % request.META.get('REMOTE_ADDR'), flush=True) 33 | client_data = { 34 | "clientIP": request.META.get('REMOTE_ADDR') 35 | } 36 | cl_serializer = ClientsSerializer(data=client_data) 37 | if cl_serializer.is_valid(): 38 | cl_serializer.save() 39 | issue_client = Clients.objects.get(clientIP=request.META.get('REMOTE_ADDR')) 40 | 41 | for i in range(0, len(decoded_obj["tests"])): 42 | for j in range(0, len(decoded_obj["tests"][i]["results"])): 43 | issue_obj = decoded_obj["tests"][i]["results"][j] 44 | 45 | #if issue_obj['result'] == "INFO" or issue_obj['result'] == "NOTE": 46 | #issue_fix_status = "I" 47 | if issue_obj['result'] == 'WARN': 48 | issue_fix_status = 'N' 49 | elif issue_obj['result'] == 'PASS': 50 | issue_fix_status = 'F' 51 | 52 | # If the client has already reported issues to CSF Server 53 | try: 54 | found_obj = Issues.objects.get(checkId=issue_obj['id'],issueClientId=issue_client.clientId) 55 | print("DEBUG LOG: Issue is previously created! ID: %s" % issue_obj['id'], flush=True) 56 | found_obj.fixStatus = issue_fix_status 57 | found_obj.save() 58 | serializer = IssuesSerializer() 59 | # If the client has NOT already reported issues 60 | except: 61 | print("DEBUG LOG: New Issue for this client! Check: %s, Client Id: %s" % (issue_obj['id'], issue_client.clientId) , flush=True) 62 | issue_data = { 63 | "checkId": issue_obj['id'], 64 | "checkDesc": issue_obj['desc'], 65 | "severity": checks_data[issue_obj['id']]['severity'], 66 | "issueClientId": issue_client.clientId, 67 | "fixStatus": issue_fix_status 68 | } 69 | serializer = IssuesSerializer(data=issue_data) 70 | if serializer.is_valid(): 71 | serializer.save() 72 | 73 | return Response(serializer.data, status=status.HTTP_201_CREATED) 74 | 75 | 76 | @api_view(['GET', 'PUT', 'DELETE']) 77 | def issues_view_details(request, pk): 78 | # Functionality 1: To view specific issues 79 | # Functionality 2: To edit specific issues 80 | # Functionality 3: To delete specific issues 81 | try: 82 | issue = Issues.objects.get(pk=pk) 83 | except Issues.DoesNotExist: 84 | return Response(status=status.HTTP_404_NOT_FOUND) 85 | 86 | if request.method == 'GET': 87 | serializer = IssuesSerializer(issue) 88 | return Response(serializer.data) 89 | if request.method == 'PUT': 90 | if request.POST.get('severity'): 91 | issue.severity = request.POST.get('severity') 92 | if request.POST.get('fixStatus'): 93 | issue.fixStatus = request.POST.get('fixStatus') 94 | if request.POST.get('checkComment'): 95 | issue.checkComment = request.POST.get('checkComment') 96 | issue.save() 97 | serializer = IssuesSerializer(issue) 98 | return Response(serializer.data) 99 | if request.method == 'DELETE': 100 | issue.delete() 101 | return Response(status=status.HTTP_204_NO_CONTENT) 102 | 103 | 104 | @api_view(['GET']) 105 | def clients_view(request): 106 | if request.method == 'GET': 107 | clients = Clients.objects.all() 108 | serializer = ClientsSerializer(clients, many=True) 109 | return Response(serializer.data) 110 | 111 | 112 | @api_view(['GET', 'PUT', 'DELETE']) 113 | def clients_view_details(request, pk): 114 | try: 115 | client = Clients.objects.get(pk=pk) 116 | except Clients.DoesNotExist: 117 | return Response(status=status.HTTP_404_NOT_FOUND) 118 | 119 | if request.method == 'GET': 120 | serializer = ClientsSerializer(client) 121 | return Response(serializer.data) 122 | if request.method == 'PUT': 123 | if request.POST.get('clientName'): 124 | client.clientName = request.POST.get('clientName') 125 | if request.POST.get('clientPrefs'): 126 | client.clientPrefs = request.POST.get('clientPrefs') 127 | if request.POST.get('clientGroupID'): 128 | client.clientGroupID = request.POST.get('clientGroupID') 129 | 130 | client.save() 131 | serializer = ClientsSerializer(client) 132 | return Response(serializer.data) 133 | if request.method == 'DELETE': 134 | client.delete() 135 | return Response(status=status.HTTP_204_NO_CONTENT) 136 | 137 | 138 | @api_view(['GET', 'POST']) 139 | def clientgroups_view(request): 140 | if request.method == 'GET': 141 | clientgroups = ClientGroups.objects.all() 142 | serializer = ClientGroupsSerializer(clientgroups, many=True) 143 | return Response(serializer.data) 144 | 145 | if request.method == 'POST': 146 | clientgroup_data = { 147 | "groupName": request.POST.get('groupName') if request.POST.get('groupName') else "", 148 | "groupPrefs": request.POST.get('groupPrefs') if request.POST.get('groupPrefs') else "", 149 | } 150 | clg_serializer = ClientGroupsSerializer(data=clientgroup_data) 151 | if clg_serializer.is_valid(): 152 | clg_serializer.save() 153 | return Response(clg_serializer.data, status=status.HTTP_201_CREATED) 154 | 155 | 156 | @api_view(['GET', 'PUT', 'DELETE']) 157 | def clientgroups_view_details(request, pk): 158 | try: 159 | clientgroup = ClientGroups.objects.get(pk=pk) 160 | except ClientGroups.DoesNotExist: 161 | return Response(status=status.HTTP_404_NOT_FOUND) 162 | 163 | if request.method == 'GET': 164 | serializer = ClientGroupsSerializer(clientgroup) 165 | return Response(serializer.data) 166 | if request.method == 'PUT': 167 | if request.POST.get('groupName'): 168 | clientgroup.groupName = request.POST.get('groupName') 169 | if request.POST.get('groupPrefs'): 170 | clientgroup.groupPrefs = request.POST.get('groupPrefs') 171 | clientgroup.save() 172 | serializer = ClientGroupsSerializer(clientgroup) 173 | return Response(serializer.data) 174 | if request.method == 'DELETE': 175 | clientgroup.delete() 176 | return Response(status=status.HTTP_204_NO_CONTENT) 177 | 178 | 179 | # TBD. Future Functionality. 180 | @api_view(['GET', 'PUT', 'POST', 'DELETE']) 181 | def users_view(request): 182 | if request.method == 'GET': 183 | users = Users.objects.all() 184 | serializer = IssuesSerializer(users, many=True) 185 | return Response(serializer.data) 186 | 187 | 188 | # TBD. Future Functionality. 189 | @api_view(['POST']) 190 | def userlogin_view(request): 191 | if request.method == 'POST': 192 | issues = Users.objects.all() 193 | serializer = UsersSerializer(issues, many=True) 194 | return Response(serializer.data) 195 | -------------------------------------------------------------------------------- /csf_server/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == '__main__': 6 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'csf_server.settings') 7 | try: 8 | from django.core.management import execute_from_command_line 9 | except ImportError as exc: 10 | raise ImportError( 11 | "Couldn't import Django. Are you sure it's installed and " 12 | "available on your PYTHONPATH environment variable? Did you " 13 | "forget to activate a virtual environment?" 14 | ) from exc 15 | execute_from_command_line(sys.argv) 16 | -------------------------------------------------------------------------------- /csf_server/requirements.txt: -------------------------------------------------------------------------------- 1 | Django==2.2.11 2 | django-rest-framework==0.1.0 3 | djangorestframework==3.9.1 4 | pytz==2018.9 5 | django-cors-headers==3.0.2 6 | gunicorn==19.9.0 7 | -------------------------------------------------------------------------------- /csf_server/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | python manage.py makemigrations 4 | python manage.py makemigrations csfapi 5 | python manage.py migrate 6 | python manage.py runserver 0.0.0.0:8000 -------------------------------------------------------------------------------- /csf_server/static/chartist.min.css: -------------------------------------------------------------------------------- 1 | .ct-double-octave:after, 2 | .ct-major-eleventh:after, 3 | .ct-major-second:after, 4 | .ct-major-seventh:after, 5 | .ct-major-sixth:after, 6 | .ct-major-tenth:after, 7 | .ct-major-third:after, 8 | .ct-major-twelfth:after, 9 | .ct-minor-second:after, 10 | .ct-minor-seventh:after, 11 | .ct-minor-sixth:after, 12 | .ct-minor-third:after, 13 | .ct-octave:after, 14 | .ct-perfect-fifth:after, 15 | .ct-perfect-fourth:after, 16 | .ct-square:after { 17 | content: ""; 18 | clear: both 19 | } 20 | 21 | .ct-label { 22 | fill: rgba(0, 0, 0, .4); 23 | color: rgba(0, 0, 0, .4); 24 | font-size: .75rem; 25 | line-height: 1; 26 | font-weight: bold 27 | } 28 | 29 | .ct-grid-background, 30 | .ct-line { 31 | fill: none 32 | } 33 | 34 | .ct-chart-bar .ct-label, 35 | .ct-chart-line .ct-label { 36 | display: block; 37 | display: -webkit-box; 38 | display: -moz-box; 39 | display: -ms-flexbox; 40 | display: -webkit-flex; 41 | display: flex 42 | } 43 | 44 | .ct-chart-donut .ct-label, 45 | .ct-chart-pie .ct-label { 46 | dominant-baseline: central 47 | } 48 | 49 | .ct-label.ct-horizontal.ct-start { 50 | -webkit-box-align: flex-end; 51 | -webkit-align-items: flex-end; 52 | -ms-flex-align: flex-end; 53 | align-items: flex-end; 54 | -webkit-box-pack: flex-start; 55 | -webkit-justify-content: flex-start; 56 | -ms-flex-pack: flex-start; 57 | justify-content: flex-start; 58 | text-align: left; 59 | text-anchor: start 60 | } 61 | 62 | .ct-label.ct-horizontal.ct-end { 63 | -webkit-box-align: flex-start; 64 | -webkit-align-items: flex-start; 65 | -ms-flex-align: flex-start; 66 | align-items: flex-start; 67 | -webkit-box-pack: flex-start; 68 | -webkit-justify-content: flex-start; 69 | -ms-flex-pack: flex-start; 70 | justify-content: flex-start; 71 | text-align: left; 72 | text-anchor: start 73 | } 74 | 75 | .ct-label.ct-vertical.ct-start { 76 | -webkit-box-align: flex-end; 77 | -webkit-align-items: flex-end; 78 | -ms-flex-align: flex-end; 79 | align-items: flex-end; 80 | -webkit-box-pack: flex-end; 81 | -webkit-justify-content: flex-end; 82 | -ms-flex-pack: flex-end; 83 | justify-content: flex-end; 84 | text-align: right; 85 | text-anchor: end 86 | } 87 | 88 | .ct-label.ct-vertical.ct-end { 89 | -webkit-box-align: flex-end; 90 | -webkit-align-items: flex-end; 91 | -ms-flex-align: flex-end; 92 | align-items: flex-end; 93 | -webkit-box-pack: flex-start; 94 | -webkit-justify-content: flex-start; 95 | -ms-flex-pack: flex-start; 96 | justify-content: flex-start; 97 | text-align: left; 98 | text-anchor: start 99 | } 100 | 101 | .ct-chart-bar .ct-label.ct-horizontal.ct-start { 102 | -webkit-box-align: flex-end; 103 | -webkit-align-items: flex-end; 104 | -ms-flex-align: flex-end; 105 | align-items: flex-end; 106 | -webkit-box-pack: center; 107 | -webkit-justify-content: center; 108 | -ms-flex-pack: center; 109 | justify-content: center; 110 | text-align: center; 111 | text-anchor: start 112 | } 113 | 114 | .ct-chart-bar .ct-label.ct-horizontal.ct-end { 115 | -webkit-box-align: flex-start; 116 | -webkit-align-items: flex-start; 117 | -ms-flex-align: flex-start; 118 | align-items: flex-start; 119 | -webkit-box-pack: center; 120 | -webkit-justify-content: center; 121 | -ms-flex-pack: center; 122 | justify-content: center; 123 | text-align: center; 124 | text-anchor: start 125 | } 126 | 127 | .ct-chart-bar.ct-horizontal-bars .ct-label.ct-horizontal.ct-start { 128 | -webkit-box-align: flex-end; 129 | -webkit-align-items: flex-end; 130 | -ms-flex-align: flex-end; 131 | align-items: flex-end; 132 | -webkit-box-pack: flex-start; 133 | -webkit-justify-content: flex-start; 134 | -ms-flex-pack: flex-start; 135 | justify-content: flex-start; 136 | text-align: left; 137 | text-anchor: start 138 | } 139 | 140 | .ct-chart-bar.ct-horizontal-bars .ct-label.ct-horizontal.ct-end { 141 | -webkit-box-align: flex-start; 142 | -webkit-align-items: flex-start; 143 | -ms-flex-align: flex-start; 144 | align-items: flex-start; 145 | -webkit-box-pack: flex-start; 146 | -webkit-justify-content: flex-start; 147 | -ms-flex-pack: flex-start; 148 | justify-content: flex-start; 149 | text-align: left; 150 | text-anchor: start 151 | } 152 | 153 | .ct-chart-bar.ct-horizontal-bars .ct-label.ct-vertical.ct-start { 154 | -webkit-box-align: center; 155 | -webkit-align-items: center; 156 | -ms-flex-align: center; 157 | align-items: center; 158 | -webkit-box-pack: flex-end; 159 | -webkit-justify-content: flex-end; 160 | -ms-flex-pack: flex-end; 161 | justify-content: flex-end; 162 | text-align: right; 163 | text-anchor: end 164 | } 165 | 166 | .ct-chart-bar.ct-horizontal-bars .ct-label.ct-vertical.ct-end { 167 | -webkit-box-align: center; 168 | -webkit-align-items: center; 169 | -ms-flex-align: center; 170 | align-items: center; 171 | -webkit-box-pack: flex-start; 172 | -webkit-justify-content: flex-start; 173 | -ms-flex-pack: flex-start; 174 | justify-content: flex-start; 175 | text-align: left; 176 | text-anchor: end 177 | } 178 | 179 | .ct-grid { 180 | stroke: rgba(0, 0, 0, .2); 181 | stroke-width: 1px; 182 | stroke-dasharray: 2px 183 | } 184 | 185 | .ct-point { 186 | stroke-width: 10px; 187 | stroke-linecap: round 188 | } 189 | 190 | .ct-line { 191 | stroke-width: 4px 192 | } 193 | 194 | .ct-area { 195 | stroke: none; 196 | fill-opacity: .1 197 | } 198 | 199 | .ct-bar { 200 | fill: none; 201 | stroke-width: 50px 202 | } 203 | 204 | .ct-slice-donut { 205 | fill: none; 206 | stroke-width: 60px 207 | } 208 | 209 | .ct-series-a .ct-bar, 210 | .ct-series-a .ct-line, 211 | .ct-series-a .ct-point, 212 | .ct-series-a .ct-slice-donut { 213 | stroke: #960f11 214 | } 215 | 216 | .ct-series-a .ct-area, 217 | .ct-series-a .ct-slice-donut-solid, 218 | .ct-series-a .ct-slice-pie { 219 | fill: #960f11 220 | } 221 | 222 | .ct-series-b .ct-bar, 223 | .ct-series-b .ct-line, 224 | .ct-series-b .ct-point, 225 | .ct-series-b .ct-slice-donut { 226 | stroke: #f4c63d 227 | } 228 | 229 | .ct-series-b .ct-area, 230 | .ct-series-b .ct-slice-donut-solid, 231 | .ct-series-b .ct-slice-pie { 232 | fill: #f4c63d 233 | } 234 | 235 | .ct-series-c .ct-bar, 236 | .ct-series-c .ct-line, 237 | .ct-series-c .ct-point, 238 | .ct-series-c .ct-slice-donut { 239 | stroke: #25733f 240 | } 241 | 242 | .ct-series-c .ct-area, 243 | .ct-series-c .ct-slice-donut-solid, 244 | .ct-series-c .ct-slice-pie { 245 | fill: #25733f 246 | } 247 | 248 | .ct-series-d .ct-bar, 249 | .ct-series-d .ct-line, 250 | .ct-series-d .ct-point, 251 | .ct-series-d .ct-slice-donut { 252 | stroke: #706766 253 | } 254 | 255 | .ct-series-d .ct-area, 256 | .ct-series-d .ct-slice-donut-solid, 257 | .ct-series-d .ct-slice-pie { 258 | fill: #706766 259 | } 260 | 261 | .ct-series-e .ct-bar, 262 | .ct-series-e .ct-line, 263 | .ct-series-e .ct-point, 264 | .ct-series-e .ct-slice-donut { 265 | stroke: #453d3f 266 | } 267 | 268 | .ct-series-e .ct-area, 269 | .ct-series-e .ct-slice-donut-solid, 270 | .ct-series-e .ct-slice-pie { 271 | fill: #453d3f 272 | } 273 | 274 | .ct-series-f .ct-bar, 275 | .ct-series-f .ct-line, 276 | .ct-series-f .ct-point, 277 | .ct-series-f .ct-slice-donut { 278 | stroke: #59922b 279 | } 280 | 281 | .ct-series-f .ct-area, 282 | .ct-series-f .ct-slice-donut-solid, 283 | .ct-series-f .ct-slice-pie { 284 | fill: #59922b 285 | } 286 | 287 | .ct-series-g .ct-bar, 288 | .ct-series-g .ct-line, 289 | .ct-series-g .ct-point, 290 | .ct-series-g .ct-slice-donut { 291 | stroke: #0544d3 292 | } 293 | 294 | .ct-series-g .ct-area, 295 | .ct-series-g .ct-slice-donut-solid, 296 | .ct-series-g .ct-slice-pie { 297 | fill: #0544d3 298 | } 299 | 300 | .ct-series-h .ct-bar, 301 | .ct-series-h .ct-line, 302 | .ct-series-h .ct-point, 303 | .ct-series-h .ct-slice-donut { 304 | stroke: #6b0392 305 | } 306 | 307 | .ct-series-h .ct-area, 308 | .ct-series-h .ct-slice-donut-solid, 309 | .ct-series-h .ct-slice-pie { 310 | fill: #6b0392 311 | } 312 | 313 | .ct-series-i .ct-bar, 314 | .ct-series-i .ct-line, 315 | .ct-series-i .ct-point, 316 | .ct-series-i .ct-slice-donut { 317 | stroke: #f05b4f 318 | } 319 | 320 | .ct-series-i .ct-area, 321 | .ct-series-i .ct-slice-donut-solid, 322 | .ct-series-i .ct-slice-pie { 323 | fill: #f05b4f 324 | } 325 | 326 | .ct-series-j .ct-bar, 327 | .ct-series-j .ct-line, 328 | .ct-series-j .ct-point, 329 | .ct-series-j .ct-slice-donut { 330 | stroke: #dda458 331 | } 332 | 333 | .ct-series-j .ct-area, 334 | .ct-series-j .ct-slice-donut-solid, 335 | .ct-series-j .ct-slice-pie { 336 | fill: #dda458 337 | } 338 | 339 | .ct-series-k .ct-bar, 340 | .ct-series-k .ct-line, 341 | .ct-series-k .ct-point, 342 | .ct-series-k .ct-slice-donut { 343 | stroke: #eacf7d 344 | } 345 | 346 | .ct-series-k .ct-area, 347 | .ct-series-k .ct-slice-donut-solid, 348 | .ct-series-k .ct-slice-pie { 349 | fill: #eacf7d 350 | } 351 | 352 | .ct-series-l .ct-bar, 353 | .ct-series-l .ct-line, 354 | .ct-series-l .ct-point, 355 | .ct-series-l .ct-slice-donut { 356 | stroke: #86797d 357 | } 358 | 359 | .ct-series-l .ct-area, 360 | .ct-series-l .ct-slice-donut-solid, 361 | .ct-series-l .ct-slice-pie { 362 | fill: #86797d 363 | } 364 | 365 | .ct-series-m .ct-bar, 366 | .ct-series-m .ct-line, 367 | .ct-series-m .ct-point, 368 | .ct-series-m .ct-slice-donut { 369 | stroke: #b2c326 370 | } 371 | 372 | .ct-series-m .ct-area, 373 | .ct-series-m .ct-slice-donut-solid, 374 | .ct-series-m .ct-slice-pie { 375 | fill: #b2c326 376 | } 377 | 378 | .ct-series-n .ct-bar, 379 | .ct-series-n .ct-line, 380 | .ct-series-n .ct-point, 381 | .ct-series-n .ct-slice-donut { 382 | stroke: #6188e2 383 | } 384 | 385 | .ct-series-n .ct-area, 386 | .ct-series-n .ct-slice-donut-solid, 387 | .ct-series-n .ct-slice-pie { 388 | fill: #6188e2 389 | } 390 | 391 | .ct-series-o .ct-bar, 392 | .ct-series-o .ct-line, 393 | .ct-series-o .ct-point, 394 | .ct-series-o .ct-slice-donut { 395 | stroke: #a748ca 396 | } 397 | 398 | .ct-series-o .ct-area, 399 | .ct-series-o .ct-slice-donut-solid, 400 | .ct-series-o .ct-slice-pie { 401 | fill: #a748ca 402 | } 403 | 404 | .ct-square { 405 | display: block; 406 | position: relative; 407 | width: 100% 408 | } 409 | 410 | .ct-square:before { 411 | display: block; 412 | float: left; 413 | content: ""; 414 | width: 0; 415 | height: 0; 416 | padding-bottom: 100% 417 | } 418 | 419 | .ct-square:after { 420 | display: table 421 | } 422 | 423 | .ct-square>svg { 424 | display: block; 425 | position: absolute; 426 | top: 0; 427 | left: 0 428 | } 429 | 430 | .ct-minor-second { 431 | display: block; 432 | position: relative; 433 | width: 100% 434 | } 435 | 436 | .ct-minor-second:before { 437 | display: block; 438 | float: left; 439 | content: ""; 440 | width: 0; 441 | height: 0; 442 | padding-bottom: 93.75% 443 | } 444 | 445 | .ct-minor-second:after { 446 | display: table 447 | } 448 | 449 | .ct-minor-second>svg { 450 | display: block; 451 | position: absolute; 452 | top: 0; 453 | left: 0 454 | } 455 | 456 | .ct-major-second { 457 | display: block; 458 | position: relative; 459 | width: 100% 460 | } 461 | 462 | .ct-major-second:before { 463 | display: block; 464 | float: left; 465 | content: ""; 466 | width: 0; 467 | height: 0; 468 | padding-bottom: 88.8888888889% 469 | } 470 | 471 | .ct-major-second:after { 472 | display: table 473 | } 474 | 475 | .ct-major-second>svg { 476 | display: block; 477 | position: absolute; 478 | top: 0; 479 | left: 0 480 | } 481 | 482 | .ct-minor-third { 483 | display: block; 484 | position: relative; 485 | width: 100% 486 | } 487 | 488 | .ct-minor-third:before { 489 | display: block; 490 | float: left; 491 | content: ""; 492 | width: 0; 493 | height: 0; 494 | padding-bottom: 83.3333333333% 495 | } 496 | 497 | .ct-minor-third:after { 498 | display: table 499 | } 500 | 501 | .ct-minor-third>svg { 502 | display: block; 503 | position: absolute; 504 | top: 0; 505 | left: 0 506 | } 507 | 508 | .ct-major-third { 509 | display: block; 510 | position: relative; 511 | width: 100% 512 | } 513 | 514 | .ct-major-third:before { 515 | display: block; 516 | float: left; 517 | content: ""; 518 | width: 0; 519 | height: 0; 520 | padding-bottom: 80% 521 | } 522 | 523 | .ct-major-third:after { 524 | display: table 525 | } 526 | 527 | .ct-major-third>svg { 528 | display: block; 529 | position: absolute; 530 | top: 0; 531 | left: 0 532 | } 533 | 534 | .ct-perfect-fourth { 535 | display: block; 536 | position: relative; 537 | width: 100% 538 | } 539 | 540 | .ct-perfect-fourth:before { 541 | display: block; 542 | float: left; 543 | content: ""; 544 | width: 0; 545 | height: 0; 546 | padding-bottom: 75% 547 | } 548 | 549 | .ct-perfect-fourth:after { 550 | display: table 551 | } 552 | 553 | .ct-perfect-fourth>svg { 554 | display: block; 555 | position: absolute; 556 | top: 0; 557 | left: 0 558 | } 559 | 560 | .ct-perfect-fifth { 561 | display: block; 562 | position: relative; 563 | width: 100% 564 | } 565 | 566 | .ct-perfect-fifth:before { 567 | display: block; 568 | float: left; 569 | content: ""; 570 | width: 0; 571 | height: 0; 572 | padding-bottom: 66.6666666667% 573 | } 574 | 575 | .ct-perfect-fifth:after { 576 | display: table 577 | } 578 | 579 | .ct-perfect-fifth>svg { 580 | display: block; 581 | position: absolute; 582 | top: 0; 583 | left: 0 584 | } 585 | 586 | .ct-minor-sixth { 587 | display: block; 588 | position: relative; 589 | width: 100% 590 | } 591 | 592 | .ct-minor-sixth:before { 593 | display: block; 594 | float: left; 595 | content: ""; 596 | width: 0; 597 | height: 0; 598 | padding-bottom: 62.5% 599 | } 600 | 601 | .ct-minor-sixth:after { 602 | display: table 603 | } 604 | 605 | .ct-minor-sixth>svg { 606 | display: block; 607 | position: absolute; 608 | top: 0; 609 | left: 0 610 | } 611 | 612 | .ct-golden-section { 613 | display: block; 614 | position: relative; 615 | width: 100% 616 | } 617 | 618 | .ct-golden-section:before { 619 | display: block; 620 | float: left; 621 | content: ""; 622 | width: 0; 623 | height: 0; 624 | padding-bottom: 61.804697157% 625 | } 626 | 627 | .ct-golden-section:after { 628 | content: ""; 629 | display: table; 630 | clear: both 631 | } 632 | 633 | .ct-golden-section>svg { 634 | display: block; 635 | position: absolute; 636 | top: 0; 637 | left: 0 638 | } 639 | 640 | .ct-major-sixth { 641 | display: block; 642 | position: relative; 643 | width: 100% 644 | } 645 | 646 | .ct-major-sixth:before { 647 | display: block; 648 | float: left; 649 | content: ""; 650 | width: 0; 651 | height: 0; 652 | padding-bottom: 60% 653 | } 654 | 655 | .ct-major-sixth:after { 656 | display: table 657 | } 658 | 659 | .ct-major-sixth>svg { 660 | display: block; 661 | position: absolute; 662 | top: 0; 663 | left: 0 664 | } 665 | 666 | .ct-minor-seventh { 667 | display: block; 668 | position: relative; 669 | width: 100% 670 | } 671 | 672 | .ct-minor-seventh:before { 673 | display: block; 674 | float: left; 675 | content: ""; 676 | width: 0; 677 | height: 0; 678 | padding-bottom: 56.25% 679 | } 680 | 681 | .ct-minor-seventh:after { 682 | display: table 683 | } 684 | 685 | .ct-minor-seventh>svg { 686 | display: block; 687 | position: absolute; 688 | top: 0; 689 | left: 0 690 | } 691 | 692 | .ct-major-seventh { 693 | display: block; 694 | position: relative; 695 | width: 100% 696 | } 697 | 698 | .ct-major-seventh:before { 699 | display: block; 700 | float: left; 701 | content: ""; 702 | width: 0; 703 | height: 0; 704 | padding-bottom: 53.3333333333% 705 | } 706 | 707 | .ct-major-seventh:after { 708 | display: table 709 | } 710 | 711 | .ct-major-seventh>svg { 712 | display: block; 713 | position: absolute; 714 | top: 0; 715 | left: 0 716 | } 717 | 718 | .ct-octave { 719 | display: block; 720 | position: relative; 721 | width: 100% 722 | } 723 | 724 | .ct-octave:before { 725 | display: block; 726 | float: left; 727 | content: ""; 728 | width: 0; 729 | height: 0; 730 | padding-bottom: 50% 731 | } 732 | 733 | .ct-octave:after { 734 | display: table 735 | } 736 | 737 | .ct-octave>svg { 738 | display: block; 739 | position: absolute; 740 | top: 0; 741 | left: 0 742 | } 743 | 744 | .ct-major-tenth { 745 | display: block; 746 | position: relative; 747 | width: 100% 748 | } 749 | 750 | .ct-major-tenth:before { 751 | display: block; 752 | float: left; 753 | content: ""; 754 | width: 0; 755 | height: 0; 756 | padding-bottom: 40% 757 | } 758 | 759 | .ct-major-tenth:after { 760 | display: table 761 | } 762 | 763 | .ct-major-tenth>svg { 764 | display: block; 765 | position: absolute; 766 | top: 0; 767 | left: 0 768 | } 769 | 770 | .ct-major-eleventh { 771 | display: block; 772 | position: relative; 773 | width: 100% 774 | } 775 | 776 | .ct-major-eleventh:before { 777 | display: block; 778 | float: left; 779 | content: ""; 780 | width: 0; 781 | height: 0; 782 | padding-bottom: 37.5% 783 | } 784 | 785 | .ct-major-eleventh:after { 786 | display: table 787 | } 788 | 789 | .ct-major-eleventh>svg { 790 | display: block; 791 | position: absolute; 792 | top: 0; 793 | left: 0 794 | } 795 | 796 | .ct-major-twelfth { 797 | display: block; 798 | position: relative; 799 | width: 100% 800 | } 801 | 802 | .ct-major-twelfth:before { 803 | display: block; 804 | float: left; 805 | content: ""; 806 | width: 0; 807 | height: 0; 808 | padding-bottom: 33.3333333333% 809 | } 810 | 811 | .ct-major-twelfth:after { 812 | display: table 813 | } 814 | 815 | .ct-major-twelfth>svg { 816 | display: block; 817 | position: absolute; 818 | top: 0; 819 | left: 0 820 | } 821 | 822 | .ct-double-octave { 823 | display: block; 824 | position: relative; 825 | width: 100% 826 | } 827 | 828 | .ct-double-octave:before { 829 | display: block; 830 | float: left; 831 | content: ""; 832 | width: 0; 833 | height: 0; 834 | padding-bottom: 25% 835 | } 836 | 837 | .ct-double-octave:after { 838 | display: table 839 | } 840 | 841 | .ct-double-octave>svg { 842 | display: block; 843 | position: absolute; 844 | top: 0; 845 | left: 0 846 | } 847 | -------------------------------------------------------------------------------- /csf_server/static/checks.json: -------------------------------------------------------------------------------- 1 | { 2 | "1.1": {"desc": "Ensure a separate partition for containers has been created", "severity": "H"}, 3 | "1.2": {"desc": "Ensure the container host has been Hardened", "severity": "I"}, 4 | "1.3": {"desc": "Ensure Docker is up to date", "severity": "I"}, 5 | "1.4": {"desc": "Ensure only trusted users are allowed to control Docker daemon", "severity": "L"}, 6 | "1.5": {"desc": "Ensure auditing is configured for the Docker daemon", "severity": "M"}, 7 | "1.6": {"desc": "Ensure auditing is configured for Docker files and directories - /var/lib/docker", "severity": "M"}, 8 | "1.7": {"desc": "Ensure auditing is configured for Docker files and directories - /etc/docker", "severity": "M"}, 9 | "1.8": {"desc": "Ensure auditing is configured for Docker files and directories - docker.service", "severity": "M"}, 10 | "1.9": {"desc": "Ensure auditing is configured for Docker files and directories - docker.socket", "severity": "M"}, 11 | "1.10": {"desc": "Ensure auditing is configured for Docker files and directories - /etc/default/docker", "severity": "M"}, 12 | "1.11": {"desc": "Ensure auditing is configured for Docker files and directories - /etc/docker/daemon.json", "severity": "M"}, 13 | "1.12": {"desc": "Ensure auditing is configured for Docker files and directories - /usr/bin/docker-containerd", "severity": "M"}, 14 | "1.13": {"desc": "Ensure auditing is configured for Docker files and directories - /usr/bin/docker-runc", "severity": "M"}, 15 | 16 | "2.1": {"desc": "Ensure network traffic is restricted between containers on the default bridge", "severity": "H"}, 17 | "2.2": {"desc": "Ensure the logging level is set to 'info'", "severity": "L"}, 18 | "2.3": {"desc": "Ensure Docker is allowed to make changes to iptables", "severity": "M"}, 19 | "2.4": {"desc": "Ensure insecure registries are not used", "severity": "H"}, 20 | "2.5": {"desc": "Ensure aufs storage driver is not used", "severity": "M"}, 21 | "2.6": {"desc": "Ensure TLS authentication for Docker daemon is configured", "severity": "H"}, 22 | "2.7": {"desc": "Ensure the default ulimit is configured appropriately", "severity": "I"}, 23 | "2.8": {"desc": "Enable user namespace support", "severity": "H"}, 24 | "2.9": {"desc": "Ensure the default cgroup usage has been confirmed", "severity": "M"}, 25 | "2.10": {"desc": "Ensure base device size is not changed until needed", "severity": "L"}, 26 | "2.11": {"desc": "Ensure that authorization for Docker client commands is enabled", "severity": "H"}, 27 | "2.12": {"desc": "Ensure centralized and remote logging is configured", "severity": "M"}, 28 | "2.13": {"desc": "Ensure operations on legacy registry (v1) are Disabled", "severity": "I"}, 29 | "2.14": {"desc": "Ensure live restore is Enabled", "severity": "L"}, 30 | "2.15": {"desc": "Ensure Userland Proxy is Disabled", "severity": "M"}, 31 | "2.16": {"desc": "Ensure daemon-wide custom seccomp profile is applied, if needed", "severity": "I"}, 32 | "2.17": {"desc": "Ensure experimental features are avoided in production", "severity": "L"}, 33 | "2.18": {"desc": "Ensure containers are restricted from acquiring new privileges", "severity": "H"}, 34 | 35 | "3.1": {"desc": "Ensure that docker.service file ownership is set to root:root", "severity": "M"}, 36 | "3.2": {"desc": "Ensure that docker.service file permissions are set to 644 or more restrictive", "severity": "M"}, 37 | "3.3": {"desc": "Ensure that docker.socket file ownership is set to root:root", "severity": "M"}, 38 | "3.4": {"desc": "Ensure that docker.socket file permissions are set to 644 or more restrictive", "severity": "M"}, 39 | "3.5": {"desc": "Ensure that /etc/docker directory ownership is set to root:root", "severity": "M"}, 40 | "3.6": {"desc": "Ensure that /etc/docker directory permissions are set to 755 or more restrictive", "severity": "M"}, 41 | "3.7": {"desc": "Ensure that registry certificate file ownership is set to root:root", "severity": "L"}, 42 | "3.8": {"desc": "Ensure that registry certificate file permissions are set to 444 or more restrictive", "severity": "L"}, 43 | "3.9": {"desc": "Ensure that TLS CA certificate file ownership is set to root:root", "severity": "L"}, 44 | "3.10": {"desc": "Ensure that TLS CA certificate file permissions are set to 444 or more restrictive", "severity": "L"}, 45 | "3.11": {"desc": "Ensure that Docker server certificate file ownership is set to root:root", "severity": "L"}, 46 | "3.12": {"desc": "Ensure that Docker server certificate file permissions are set to 444 or more restrictive", "severity": "L"}, 47 | "3.13": {"desc": "Ensure that Docker server certificate key file ownership is set to root:root", "severity": "L"}, 48 | "3.14": {"desc": "Ensure that Docker server certificate key file permissions are set to 400", "severity": "L"}, 49 | "3.15": {"desc": "Ensure that Docker socket file ownership is set to root:docker", "severity": "L"}, 50 | "3.16": {"desc": "Ensure that Docker socket file permissions are set to 660 or more restrictive", "severity": "L"}, 51 | "3.17": {"desc": "Ensure that daemon.json file ownership is set to root:root", "severity": "L"}, 52 | "3.18": {"desc": "Ensure that daemon.json file permissions are set to 644 or more restrictive", "severity": "L"}, 53 | "3.19": {"desc": "Ensure that /etc/default/docker file ownership is set to root:root", "severity": "L"}, 54 | "3.20": {"desc": "Ensure that /etc/default/docker file permissions are set to 644 or more restrictive", "severity": "L"}, 55 | 56 | "4.1": {"desc": "Ensure a user for the container has been created", "severity": "M"}, 57 | "4.2": {"desc": "Ensure that containers use trusted base images", "severity": "I"}, 58 | "4.3": {"desc": "Ensure unnecessary packages are not installed in the container", "severity": "I"}, 59 | "4.4": {"desc": "Ensure images are scanned and rebuilt to include security patches", "severity": "I"}, 60 | "4.5": {"desc": "Ensure Content trust for Docker is Enabled", "severity": "H"}, 61 | "4.6": {"desc": "Ensure HEALTHCHECK instructions have been added to the container image", "severity": "M"}, 62 | "4.7": {"desc": "Ensure update instructions are not use alone in the Dockerfile", "severity": "I"}, 63 | "4.8": {"desc": "Ensure setuid and setgid permissions are removed in the images", "severity": "I"}, 64 | "4.9": {"desc": "Ensure COPY is used instead of ADD in Dockerfile", "severity": "I"}, 65 | "4.10": {"desc": "Ensure secrets are not stored in Dockerfiles", "severity": "I"}, 66 | "4.11": {"desc": "Ensure verified packages are only Installed", "severity": "I"}, 67 | 68 | "6.1": {"desc": "Avoid image sprawl", "severity": "I"}, 69 | "6.2": {"desc": "Avoid container sprawl", "severity": "I"}, 70 | 71 | "7.1": {"desc": "Ensure swarm mode is not Enabled, if not needed", "severity": "M"}, 72 | "7.2": {"desc": "Ensure the minimum number of manager nodes have been created in a swarm", "severity": "M"}, 73 | "7.3": {"desc": "Ensure swarm services are binded to a specific host interface", "severity": "M"}, 74 | "7.4": {"desc": "Ensure data exchanged between containers are encrypted on different nodes on the overlay network", "severity": "H"}, 75 | "7.5": {"desc": "Ensure Docker's secret management commands are used for managing secrets in a Swarm cluster", "severity": "I"}, 76 | "7.6": {"desc": "Ensure swarm manager is run in auto-lock mode", "severity": "M"}, 77 | "7.7": {"desc": "Ensure swarm manager auto-lock key is rotated periodically", "severity": "I"}, 78 | "7.8": {"desc": "Ensure node certificates are rotated as appropriate", "severity": "I"}, 79 | "7.9": {"desc": "Ensure CA certificates are rotated as appropriate", "severity": "I"}, 80 | "7.10": {"desc": "Ensure management plane traffic has been separated from data plane traffic", "severity": "I"} 81 | } -------------------------------------------------------------------------------- /csf_server/static/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | box-sizing: border-box; 3 | } 4 | 5 | body { 6 | font-family: Arial, Helvetica, sans-serif; 7 | } 8 | 9 | /* Style the header */ 10 | header { 11 | background-color: #666; 12 | padding: 30px; 13 | text-align: center; 14 | font-size: 35px; 15 | color: white; 16 | } 17 | 18 | /* Create two columns/boxes that floats next to each other */ 19 | nav { 20 | float: left; 21 | width: 20%; 22 | height: 1000px; 23 | background: #ccc; 24 | padding: 20px; 25 | } 26 | 27 | /* Style the list inside the menu */ 28 | nav ul { 29 | list-style-type: none; 30 | padding: 0; 31 | } 32 | 33 | article { 34 | float: left; 35 | padding: 20px; 36 | width: 80%; 37 | background-color: #f1f1f1; 38 | height: 1000px; /* only for demonstration, should be removed */ 39 | } 40 | 41 | /* Clear floats after the columns */ 42 | section:after { 43 | content: ""; 44 | display: table; 45 | clear: both; 46 | } 47 | 48 | /* Style the footer */ 49 | footer { 50 | background-color: #777; 51 | padding: 10px; 52 | text-align: center; 53 | color: white; 54 | } 55 | 56 | /* Responsive layout - makes the two columns/boxes stack on top of each other instead of next to each other, on small screens */ 57 | @media (max-width: 600px) { 58 | nav, article { 59 | width: 100%; 60 | height: auto; 61 | } 62 | } 63 | 64 | .main-dashboard { 65 | margin: auto; 66 | } 67 | -------------------------------------------------------------------------------- /csf_server/templates/bottom.html: -------------------------------------------------------------------------------- 1 | 2 | {% include "footer.html" %} 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /csf_server/templates/footer.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /csf_server/templates/header.html: -------------------------------------------------------------------------------- 1 |
2 |

ArmourBird CSF - Container Security Framework

3 |
4 | -------------------------------------------------------------------------------- /csf_server/templates/navigation.html: -------------------------------------------------------------------------------- 1 | 2 | 14 | -------------------------------------------------------------------------------- /csf_server/templates/screens/add-clientgroup.html: -------------------------------------------------------------------------------- 1 | {% include "top.html" %} 2 | 3 | 4 | 5 | {% include "bottom.html" %} -------------------------------------------------------------------------------- /csf_server/templates/screens/dashboard.html: -------------------------------------------------------------------------------- 1 | {% include "top.html" %} 2 | 3 | 4 |
5 |
6 |
7 |
8 |
9 |
10 | 11 | 79 | 80 | 81 | {% include "bottom.html" %} -------------------------------------------------------------------------------- /csf_server/templates/screens/screen-template.html: -------------------------------------------------------------------------------- 1 | {% include "top.html" %} 2 | 3 | 4 | 5 | {% include "bottom.html" %} -------------------------------------------------------------------------------- /csf_server/templates/screens/update-client.html: -------------------------------------------------------------------------------- 1 | {% include "top.html" %} 2 | 3 | 4 | 5 | {% include "bottom.html" %} -------------------------------------------------------------------------------- /csf_server/templates/screens/update-clientgroup.html: -------------------------------------------------------------------------------- 1 | {% include "top.html" %} 2 | 3 | 4 | 5 | {% include "bottom.html" %} -------------------------------------------------------------------------------- /csf_server/templates/screens/update-issue.html: -------------------------------------------------------------------------------- 1 | {% include "top.html" %} 2 | 3 | 4 | 5 | {% include "bottom.html" %} -------------------------------------------------------------------------------- /csf_server/templates/screens/view-all-issues.html: -------------------------------------------------------------------------------- 1 | {% include "top.html" %} 2 | 3 | 4 |
5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
S No.Client IPCheck IDDescriptionSeverityFix Status
19 |
20 | 68 | 69 | {% include "bottom.html" %} -------------------------------------------------------------------------------- /csf_server/templates/screens/view-clientgroup.html: -------------------------------------------------------------------------------- 1 | {% include "top.html" %} 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
S No.Clients Group IdClients Group NameClients Group Prefs
16 |
17 | 18 | 19 | 50 | 51 | 52 | {% include "bottom.html" %} -------------------------------------------------------------------------------- /csf_server/templates/screens/view-clients.html: -------------------------------------------------------------------------------- 1 | {% include "top.html" %} 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
S No.Client IdCheck IPClient NameClient PreferencesClient GroupID
18 |
19 | 20 | 54 | 55 | {% include "bottom.html" %} -------------------------------------------------------------------------------- /csf_server/templates/screens/view-issue.html: -------------------------------------------------------------------------------- 1 | {% include "top.html" %} 2 | 3 | 4 |
5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 |
issueId:
checkId:
checkDesc:
severity:
clientIP:
creationDate:
checkComment:
35 |
36 | 37 | 67 | 68 | {% include "bottom.html" %} -------------------------------------------------------------------------------- /csf_server/templates/screens/view-issues-client.html: -------------------------------------------------------------------------------- 1 | {% include "top.html" %} 2 | 3 | 4 | 5 | {% include "bottom.html" %} -------------------------------------------------------------------------------- /csf_server/templates/screens/view-issues-clientgroup.html: -------------------------------------------------------------------------------- 1 | {% include "top.html" %} 2 | 3 | 4 | 5 | {% include "bottom.html" %} -------------------------------------------------------------------------------- /csf_server/templates/static-head.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ArmourBird CSF - Container Security Framework 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /csf_server/templates/top.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | {% include "static-head.html" %} 4 | 5 | {% include "header.html" %} 6 |
7 | {% include "navigation.html" %} --------------------------------------------------------------------------------