EIO-247: add converters scripts

This commit is contained in:
Nelson Roberts
2020-02-19 10:53:53 -07:00
parent db19316701
commit 147506ead0
50 changed files with 1130 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
FROM debian:latest
RUN apt-get update
RUN apt-get -y install build-essential python3-dev python3-pip python3-setuptools python3-wheel python3-cffi libcairo2 libpango-1.0-0 libpangocairo-1.0-0 libgdk-pixbuf2.0-0 libffi-dev shared-mime-info pandoc jq
RUN apt-get clean
RUN apt-get autoclean
RUN pip3 install WeasyPrint
COPY fonts/ /usr/share/fonts/truetype/
WORKDIR /doc_tools
COPY css css/
COPY images images/
COPY templates templates/
COPY headers headers/
COPY scripts scripts/
ENTRYPOINT ["scripts/entrypoint.sh"]
+25
View File
@@ -0,0 +1,25 @@
# Converters
A collection of scripts and tools to transform documentation from one format to another. These scripts leverage docker containers to ease portability to different platforms.
### Usage
To get started first build the local docker image by running the build script:
```
build.sh
```
#### Kube-bench json results to markdown
This converter takes two positional arguments, a `kube-bench` json results file and the directory of the helper scripts used for the kube-bench execution.
```
./run_results_to_md.sh results.json kube-bench/test_helpers
```
The conversion is sent to `stdout` which can be redirected to a file to save the conversion.
#### Markdown to pdf
This converter takes a single argument, a markdown file to convert to pdf format. The resulting pdf file is saved in `output/output.pdf`
```
./run_md_to_pdf.sh ../../content/rancher/v2.x/en/security/hardening-2.3.3/_index.md
```
+3
View File
@@ -0,0 +1,3 @@
#!/bin/bash
docker build --rm -t doc_converters:latest .
@@ -0,0 +1,87 @@
body {
font-family: sans-serif;
}
h1 {
font-size: 50px;
color: #4a6482;
font-weight: 400;
margin-top: 70px;
}
h2 {
font-size: 40px;
font-weight: 400;
color: #4a6482;
background-color: ghostwhite;
padding-top: 70px;
padding-left: 10px;
padding-right: 10px;
padding-bottom: 10px;
margin-bottom: 0;
}
h3 {
font-size: 30px;
font-weight: 400;
color: white;
background-color: #8ea3be;
padding-left: 10px;
padding-right: 10px;
padding-bottom: 10px;
padding-top: 30px;
margin-top: 0;
}
h4 {
font-size: 20px;
color: #4a6482;
margin-top: 50px;
}
li {
margin-top: 12px;
margin-bottom: 10px;
}
a {
text-decoration: none;
color: #0075A8;
}
p {
margin-top: 20px;
line-height: 25px;
font-size: 15px;
}
strong {
color: #4a6482;
}
code {
background-color: ghostwhite;
line-height: 25px;
color: #4a6482;
word-wrap: break-word;
}
h4 > code {
color: #4a6482;
}
.sourceCode {
color: #333333;
background-color: #f4f4f4;
font-size: 15px;
width: 100%;
display: inline-block;
overflow-wrap: break-word;
word-wrap: break-word;
word-break: normal;
line-break: strict;
hyphens: none;
-webkit-hyphens: none;
-moz-hyphens: none;
white-space: normal;
padding-right: 50px;
}
+358
View File
@@ -0,0 +1,358 @@
/*
Theme Name: Linux Academy Study Guide Template 08-14-2019
*/
@font-face {font-family: Poppins;src: url(./fonts/Poppins/Poppins-Regular.ttf);}
@font-face {font-family: Roboto;src: url(./fonts/Roboto/Roboto-Regular.ttf);}
@font-face {font-family: PoppinsExtraLight; src: url(./fonts/Poppins/Poppins-ExtraLight.ttf);}
/* This lighter one is only used as H1, and in the table of contents */
@page :first {
size: portrait;
padding:0cm;
border-left-style: none;
background:none;
background: url("../images/rancher-logo-stacked-color.png") no-repeat left;
background-size: 10cm;
background-position: top 1cm left;
margin-top:1cm;
margin-bottom:1cm;
margin-left:1cm;
@top-left {
background: #000;
color:#fff;
content: "v2.3.4";
height: 1cm;
text-align: center;
width: 5cm;
font-size:1em;
font-weight:bold;}
@top-center {
background: none;
content: ''; }
@top-right {
background: none;
content: ''; }
/*
@bottom-left {
height: 1.5cm;
width:4.6cm;
background-color:#000;
content: url("images/white_logo.png");
}
*/
@bottom-left img {padding-left:.4cm;float: none;margin-top:-.2cm;}
@bottom-center {
background: none;
content: ''; }
@bottom-right {
background: none;
content: ''; }
@bottom-right-corner {
background: none;
border-left: 1px solid #fff;
content: '';}
}
@page {
font-family: Poppins;
size: portrait;
margin-top:1cm;
padding:.5cm;
border-left-style: dashed; border-left-width: 1px; border-color: #000;
@top-left {
background: #000;
color:#fff;
content: "" string(title);
height: 1cm;
text-align: center;
width: auto;
font-size:1em;
font-weight:bold;
padding-right:.5cm;
padding-left:.5cm;
}
@top-center {
background: none;
content: none;
margin-bottom: 2cm;
}
@top-right {
background: none;
content: none;}
@bottom-left {
background: none;
content: none; }
@bottom-right {
content: url("../images/rancher_logo.svg");
height: 1cm;
vertical-align: middle;
margin-top:.4cm;
width: 5.5cm; }
@bottom-right img {width:10%;/*height:auto;*/padding-right:.2cm;padding-top:.1cm;}
@bottom-right-corner {
background: #fff;
content: counter(page);
width: 2cm;
height:.5cm;
border-left: 1px solid #000;
margin-top:.5cm;
padding:.2cm;
font-size: 10pt;}
}
@page :blank {
size: portrait;
@top-left {
padding:0cm;
background: #000;
color:#fff;
content: "Rancher 2.3.x";
height: 1cm;
text-align: center;
width: 5cm;
font-size:1em;
font-weight:bold;}
@top-center {
content: none; }
@top-right {
content: none; }
@bottom-right {
background: none;
content: ''; }
@bottom-right-corner {
background: none;
border-left: 1px solid #fff;
content: '';}
}
@page no-chapter {
size: portrait;
border-left-style: none;
@top-left {
background: #000;
color:#fff;
content: "" string(title);
height: 1cm;
text-align: center;
width: auto;
font-size:1em;
font-weight:bold;
padding-right:.5cm;
padding-left:.5cm;}
@top-center {
content: none; }
@top-right {
content: none; }
@bottom-left {
background: none;
content: none; }
@bottom-center {
content: none; }
@bottom-right {
content: url("../images/rancher_logo.svg");
font-size: 9pt;
height: 1cm;
vertical-align: middle;
margin-top:.4cm;
width: 5.5cm; }
@bottom-right img {width:20%;/*height:auto;*/padding-right:.2cm;padding-top:.1cm;}
}
body { font-family: Poppins;color: #000; line-height:1.25em;padding:.25cm;}
header{/*margin-left:11cm;*/ margin-top:10cm;border-left: 1px solid #aaa;min-height:6.5cm;}
#header_bottom_text{/*position:absolute;bottom:6.2cm;*/}
h1.title {font-family:PoppinsExtraLight;font-weight:100;font-size:2.5em;line-height:1em; padding-left:1cm;}
p.subtitle{margin-left:1cm;margin-bottom:1.5cm;font-weight:bold;}
p.author{margin-left:1cm;margin-top:0; margin-bottom:0;font-weight:bold;}
p.email{margin-left:1cm;margin-top:0; margin-bottom:0;font-weight:bold;}
p.email a {color:#000;}
p.date{margin-left:1cm;margin-top:0; margin-bottom:0;font-weight:bold;}
#contentsbox { height:1.5cm; width:4cm; border-bottom:1px solid #aaa;margin-top:1.5cm;margin-bottom:1.5cm;}
#contentsbox p {font-family:PoppinsExtraLight;font-weight:100;font-size:2.5em;}
img {float:right;max-width:50%; height:auto;border-radius:10px;margin-left:1cm;margin-right:-1cm;}
a:link{outline:none;color:#000;font-weight:bold;}
pre {font-family: Roboto;font-size:.95em; margin-left:.5cm; background-color:#eee;padding:2px;
white-space: pre-wrap;
word-wrap: normal;}
code {font-family: Roboto;font-size:.95em;background-color:#87dcc5;padding:2px;}
pre code{background-color:#eee;}
pre.sourceCode{color:initial;}
/* ------------------- Lists --------------------------*/
/* Top level is bold, next level is numbered */
ul li {margin-left:-.25cm;font-weight:bold;}
ul li ul {list-style-type: decimal;}
ul li ul li {margin-left:-.25cm;font-weight:lighter;}
ul li ul li ul {list-style-type: none;}
/* Same as above, but top level is normal weight */
.nob ul li {margin-left:-.25cm;font-weight:normal;}
.nob ul li ul {list-style-type: decimal;}
.nob ul li ul li {margin-left:-.25cm;font-weight:lighter;}
.nob ul li ul li ul {list-style-type: none;}
/* Top level is bold, next level is just bullets, no numbers */
.nonum ul li {margin-left:-.25cm;font-weight:bold;}
.nonum ul li ul {list-style-type: disc;}
.nonum ul li ul li {margin-left:-.25cm;font-weight:lighter;}
.nonum ul li ul li ul {list-style-type: none;}
h1 {string-set:title content();}
h2 {
max-width:50%;
line-height:2em; vertical-align: middle;padding-left:1cm; padding-top:.2cm; padding-bottom:.2cm;font-size:.9em; margin-left:-1.5cm;width:60%; background-color:#fff;
border-radius:5px;
border-top: 1px solid #eee;
border-left: 1px solid #eee;
border-right: 1px solid #aaa;
border-bottom: 1px solid #aaa;
page-break-before: always;
font-size:1.5em;
}
h3 {font-size:1.4em;}
h4 {font-size:1.3em;
line-height:30px;
}
h5 {font-size:1.2em;}
h6 {font-size:1.1em;}
h1 code {background:none;}
h2 code {background:none;}
h3 code {background:none;}
h4 code {background:none;}
h5 code {background:none;}
h6 code {background:none;}
/*---------------------------------------- NAV (also known as Table of Contents) -----------------------------------------*/
/*--------------------------------------------
08-14-2019
By far, the biggest issue with this template
is the fact that the TOC is only one column.
When I have recovered from this ruckus, I
will be digging in and trying to make it work
--------------------------------------------*/
nav {position:relative;margin-left:-.5em;background: none;string-set:heading content(); page:no-chapter;page-break-after: always;}
nav ul {margin-top:0;margin-left:-.5em;list-style-type: none;}
nav ul li {margin-top:.75em; margin-bottom:1em; width:100%;}
nav ul li a {
border-radius:5px;
border-top: 1px solid #eee;
border-left: 1px solid #eee;
border-right: 1px solid #aaa;
border-bottom: 1px solid #aaa;
display:block;
height:2em;
padding-top:.6em;
padding-left:.6em;
margin-left:-1.5em;
}
nav ul li a::after {content: target-counter(attr(href url), page, decimal); float:right;margin-right:10px;}
nav ul li ul {list-style-type: none; border-left-style: dashed; border-left-width: 1px; border-color: #000; margin-top:1.5em;}
nav ul li ul li {margin-left:-.5em;color:#ff0000;}
nav ul li ul li a {border:none;font-family:PoppinsExtraLight;margin-top:-1.5em;}
nav ul li ul li a::after {font-size:.75em;}
nav code {background:none;}
nav a{text-decoration:none;outline:none;color:#000;}
table {
border-collapse: collapse;
}
td, th {
border: 1px solid #ddd;padding: 10px;
}
blockquote{color:#fff; background-color:#777;padding:2mm;border-radius:4px;border:1px solid #000;}
blockquote pre, blockquote code {background-color:#555;}
.pagebreak { page-break-before: always; }
code {
background-color: ghostwhite;
font-family: monospace;
line-height: 25px;
color: #4a6482;
word-wrap: break-word;
}
h4 > code {
color: #4a6482;
}
.sourceCode {
color: #333333;
background-color: #f4f4f4;
font-size: 15px;
width: 100%;
display: inline-block;
overflow-wrap: break-word;
word-wrap: break-word;
word-break: normal;
line-break: strict;
hyphens: none;
-webkit-hyphens: none;
-moz-hyphens: none;
white-space: normal;
padding-right: 50px;
}
/*--------------------------------------------
08-14-2019
The Python looks good here, the Bash not
so much. So we're leaving them black, at
least for now, to match the original template
--------------------------------------------*/
/*
code.sourceCode.python {color:#d49173;}
.op {color:#89d473;}
.dv {color: #ff0000;}
code.sourceCode.bash {color:#739ed4;}
.ex{color:#b473d4;}
*/
/*--------------------------------------------
08-14-2019
Here I was trying to dork with image captions,
but they keep showing up on the left
--------------------------------------------*/
/*
figure {
display: table;
}
figcaption {
display: table-caption;
caption-side: bottom;
float:right;
}
*/
+93
View File
@@ -0,0 +1,93 @@
Copyright 2014-2017 Indian Type Foundry (info@indiantypefoundry.com)
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+202
View File
@@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,36 @@
---
title: CIS Benchmark Rancher Self-Assessment Guide - Rancher v2.3.4
weight: 103
---
### CIS Kubernetes Benchmark 1.5 - Rancher 2.3.4 with Kubernetes 1.15
[Click here to download a PDF version of this document](https://releases.rancher.com/documents/security/2.3.4/Rancher_Benchmark_Assessment.pdf)
#### Overview
This document is a companion to the Rancher v2.3.4 security hardening guide. The hardening guide provides prescriptive guidance for hardening a production installation of Rancher, and this benchmark guide is meant to help you evaluate the level of security of the hardened cluster against each control in the benchmark.
This guide corresponds to specific versions of the hardening guide, Rancher, Kubernetes, and the CIS Benchmark:
Self Assessment Guide Version | Rancher Version | Hardening Guide Version | Kubernetes Version | CIS Benchmark Version
---------------------------|----------|---------|-------|-----
Self Assessment Guide v2.3.4 | Rancher v2.3.4 | Hardening Guide v2.3.4 | Kubernetes v1.15 | Benchmark v1.5
Because Rancher and RKE install Kubernetes services as Docker containers, many of the control verification checks in the CIS Kubernetes Benchmark don't apply and will have a result of `Not Applicable`. This guide will walk through the various controls and provide updated example commands to audit compliance in Rancher-created clusters.
This document is to be used by Rancher operators, security teams, auditors and decision makers.
For more detail about each audit, including rationales and remediations for failing tests, you can refer to the corresponding section of the CIS Kubernetes Benchmark v1.5. You can download the benchmark after logging in to [CISecurity.org]( https://www.cisecurity.org/benchmark/kubernetes/).
#### Testing controls methodology
Rancher and RKE install Kubernetes services via Docker containers. Configuration is defined by arguments passed to the container at the time of initialization, not via configuration files.
Scoring the commands is different in Rancher Labs than in the CIS Benchmark. Where the commands differ from the original CIS benchmark, the commands specific to Rancher Labs are provided for testing. Only **scored** tests will be covered in this guide.
When performing the tests, you will need access to the Docker command line on the hosts of all three RKE roles. The commands also make use of the the `jq` and `kubectl` (with valid config) commands to provide human-readable formatting.
### Controls
---
@@ -0,0 +1,37 @@
---
title: CIS Benchmark Rancher Self-Assessment Guide - v2.3.5
weight: 105
---
### CIS Kubernetes Benchmark 1.5 - Rancher 2.3.5 with Kubernetes 1.15
[Click here to download a PDF version of this document](https://releases.rancher.com/documents/security/2.3.5/Rancher_Benchmark_Assessment.pdf)
#### Overview
This document is a companion to the Rancher v2.3.5 security hardening guide. The hardening guide provides prescriptive guidance for hardening a production installation of Rancher, and this benchmark guide is meant to help you evaluate the level of security of the hardened cluster against each control in the benchmark.
This guide corresponds to specific versions of the hardening guide, Rancher, Kubernetes, and the CIS Benchmark:
Self Assessment Guide Version | Rancher Version | Hardening Guide Version | Kubernetes Version | CIS Benchmark Version
---------------------------|----------|---------|-------|-----
Self Assessment Guide v2.3.5 | Rancher v2.3.5 | Hardening Guide v2.3.5 | Kubernetes v1.15 | Benchmark v1.5
Because Rancher and RKE install Kubernetes services as Docker containers, many of the control verification checks in the CIS Kubernetes Benchmark don't apply and will have a result of `Not Applicable`. This guide will walk through the various controls and provide updated example commands to audit compliance in Rancher-created clusters.
This document is to be used by Rancher operators, security teams, auditors and decision makers.
For more detail about each audit, including rationales and remediations for failing tests, you can refer to the corresponding section of the CIS Kubernetes Benchmark v1.5. You can download the benchmark after logging in to [CISecurity.org]( https://www.cisecurity.org/benchmark/kubernetes/).
#### Testing controls methodology
Rancher and RKE install Kubernetes services via Docker containers. Configuration is defined by arguments passed to the container at the time of initialization, not via configuration files.
Where control audits differ from the original CIS benchmark, the audit commands specific to Rancher Labs are provided for testing.
When performing the tests, you will need access to the Docker command line on the hosts of all three RKE roles. The commands also make use of the the [jq](https://stedolan.github.io/jq/) and [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) (with valid config) tools to and are required in the testing and evaluation of test results.
> NOTE: only scored tests are covered in this guide.
### Controls
---
Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.2.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 500.2 254" style="enable-background:new 0 0 500.2 254;" xml:space="preserve">
<style type="text/css">
.st0{fill:#0075A8;}
.st1{fill:#59595B;}
.st2{fill:#CCCCCC;}
.st3{fill:#B3B3B3;}
.st4{fill:#FFFFFF;}
</style>
<g>
<g>
<path d="M1.6,169.5h34.2c16.2,0,27.2,7.9,27.2,23.1c0,12.4-8.5,19.9-16.7,22.5c2.5,2.1,4.3,4.9,5.8,7.9c3.4,7,5.8,14.8,13,14.8
c1.8,0,3.3-0.6,3.3-0.6l-1.6,14.6c0,0-4.4,1.1-8.2,1.1c-9.8,0-15.5-3.8-21.3-17c-2.5-5.9-5.9-16.2-10.5-16.2h-4.7v32.8H1.6V169.5z
M22.1,184.4v20.4h7.4c5.9,0,12.8-1.8,12.8-10.7c0-7.3-4.7-9.7-10.3-9.7H22.1z M90.8,169.5h20.8l28,83h-20.8l-5.2-15.7H85.9
l-5,15.7h-18L90.8,169.5z M90.8,221.5h17.8l-5.7-17.5c-2-5.9-2.8-14.3-2.8-14.3h-0.5c0,0-1.2,8.5-3.1,14.1L90.8,221.5z
M140.5,252.5h16.9v-39.9c0-4.5-0.6-10.1-1-14.8h0.5c1.7,4.4,3.9,9.8,6,13.5l22.6,41.1H207v-83h-16.9v39.9
c0,4.8,0.6,11.4,0.9,16.1h-0.5c-2-4.9-4.4-11.2-6.3-14.8l-21.8-41.2h-22V252.5z M211.4,210.4c0,30.3,14.5,43.5,37,43.5
c22.1,0,34.3-12.4,33-29.3l-18-1.8c1.5,10.8-5.4,16.1-13.9,16.1c-9,0-16.9-5.8-16.9-28.4c0-21.4,7.3-28,16.2-28
c9.3,0,14.5,5.3,12.4,18.5l19.2-1.7c2.7-18-7-31.2-31.2-31.2C226.3,168,211.4,180.4,211.4,210.4 M285.6,252.5h20.5v-35.2h25.2
v35.2h20.5v-83h-20.5v31.4h-25.2v-31.4h-20.5V252.5z M360.1,252.5h56.2v-15.3h-35.7v-19.4h28.9v-15.3h-28.9v-17.8h34.4v-15.3h-55
V252.5z M420.3,169.5h34.2c16.2,0,27.2,7.9,27.2,23.1c0,12.4-8.5,19.9-16.7,22.5c2.5,2.1,4.3,4.9,5.8,7.9c3.4,7,5.8,14.8,13,14.8
c1.8,0,3.3-0.6,3.3-0.6l-1.6,14.6c0,0-4.4,1.1-8.2,1.1c-9.8,0-15.5-3.8-21.3-17c-2.5-5.9-5.9-16.2-10.5-16.2h-4.7v32.8h-20.5
V169.5z M440.8,184.4v20.4h7.4c5.9,0,12.8-1.8,12.8-10.7c0-7.3-4.7-9.7-10.3-9.7H440.8z"/>
<g>
<path d="M393.2,30.7L390,11.3c-1-6.2-3.5-11.3-5.4-11.3c-1.9,0-3.5,5.2-3.5,11.5v5.1c0,6.3-5.2,11.5-11.5,11.5h-5.1
c-0.4,0-0.7,0-1.1,0V42c0.4,0,0.7,0,1.1,0h19.1C389.9,42,394.2,36.9,393.2,30.7"/>
<path d="M347.5,14.3h-30.9c-0.3,0-0.5,0-0.8,0H284c-0.4,0-0.7,0-1.1,0.1v-3c0-6.3-1.6-11.5-3.5-11.5s-4.4,5.1-5.4,11.3l-3.2,19.4
c-1,6.2,3.3,11.3,9.6,11.3h19.1c2,0,3.8-0.3,5.4-0.8c-0.6,3.3-3.5,5.7-6.9,5.7h-26.8c-4.3,0-7.6-3.9-6.9-8.2l2.7-16.3
c0.7-4.3-2.6-8.2-6.9-8.2H127c-2.8,0-5.3,1.7-6.4,4.1L95.6,56.6c-0.4,0.6-0.4,1.5,0.1,2.1l4.9,5.7c0.6,0.7,1.7,0.8,2.4,0.2
l17-13.4v81.6c0,3.9,3.1,7,7,7h37.8c3.9,0,7-3.1,7-7v-28.4c0-3.9,3.1-7,7-7h94.4c3.9,0,7,3.1,7,7v28.4c0,3.9,3.1,7,7,7H325
c3.9,0,7-3.1,7-7v-30.5h-20.1c-6.3,0-11.5-5.2-11.5-11.5V71.2c0-3.7,1.8-7.1,4.6-9.2v23.4c0,6.3,5.2,11.5,11.5,11.5h30.9
c6.3,0,11.5-5.2,11.5-11.5V25.8C358.9,19.5,353.8,14.3,347.5,14.3"/>
</g>
</g>
<g>
<path d="M487.4,173.6c0-3.9,2.9-5.6,5.6-5.6s5.6,1.7,5.6,5.6c0,3.8-2.9,5.5-5.6,5.5S487.4,177.4,487.4,173.6z M497.3,173.6
c0-3.1-2-4.4-4.2-4.4c-2.2,0-4.3,1.3-4.3,4.4c0,3,2.1,4.4,4.3,4.4C495.3,178,497.3,176.6,497.3,173.6z M491.2,170.8h2
c1,0,2,0.3,2,1.7c0,0.8-0.6,1.3-1.3,1.5l1.3,2.3H494l-1.2-2.2h-0.5v2.2h-1.1V170.8z M493.2,173.3c0.5,0,0.9-0.3,0.9-0.8
c0-0.6-0.5-0.7-0.9-0.7h-1v1.5H493.2z"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

@@ -0,0 +1 @@
<svg enable-background="new 0 0 242 108.2" viewBox="0 0 242 108.2" xmlns="http://www.w3.org/2000/svg"><g fill="#006ca1"><g clip-rule="evenodd" fill-rule="evenodd"><path d="m194.6 11.5h-12.1-13.1-25.2s.3-11.1-3-11.1-6.2 18.8-6 25.2 5 7.1 5 7.1h21c-1.1 2.3-2.9 3.5-4.3 4h-8.6-12.1s-6-.2-6-6 2.7-11.1 2-15.1-5-4-5-4h-102.9s-3 .5-4 2-20.2 29.1-20.2 29.1-.7 2.3 1 4 3 3 3 3 .7 1 3-1c2.4-2 12.1-10.1 12.1-10.1v36.4 28.2c0 2.8 2.3 5 5 5h30.2c2.8 0 5-2.3 5-5v-22.6c0-2.5 2-4.6 4.6-4.6h73.5c2.5 0 4.6 2 4.6 4.6v22.6c0 2.8 2.3 5 5 5h30.2c2.8 0 5-2.3 5-5v-24.2h-16.1c-4.5 0-8.1-3.6-8.1-8.1v-16.1c0-2.5 1.2-4.8 3-6.3v18.4c0 4.5 3.6 8.1 8.1 8.1h25.2c4.5 0 8.1-3.6 8.1-8.1v-47.3c.2-4.5-3.4-8.1-7.9-8.1z"/><path d="m206.7 21.6v11.1h17.1s6-2.1 6-8.1-4.5-24.2-7.1-24.2-3 9.7-3 15.1-6 6-6 6h-7z"/><path d="m236.5 0c-3.1 0-5.5 2.5-5.5 5.5s2.5 5.5 5.5 5.5c3.1 0 5.5-2.5 5.5-5.5s-2.5-5.5-5.5-5.5zm0 10.1c-2.5 0-4.5-2-4.5-4.5s2-4.5 4.5-4.5 4.5 2 4.5 4.5-2 4.5-4.5 4.5z"/></g><path d="m236.6 6.3h-.7v1.8h-1.2v-5.1h2c.6 0 1.1.1 1.4.4s.5.6.5 1.1c0 .3-.1.6-.2.9-.1.2-.4.4-.7.6l1 2v.1h-1.3zm-.7-1h.8c.2 0 .4-.1.5-.2s.2-.3.2-.5-.1-.4-.2-.5-.3-.1-.5-.1h-.8z"/></g></svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

+11
View File
@@ -0,0 +1,11 @@
#!/bin/bash -e
abs_path() {
echo "$(cd "$(dirname "$1")"; pwd -P)/$(basename "$1")"
}
md_source=${1:?path to markdown file is a required argument}
[ -f ${md_source} ] || (echo "file:'${results}' does not exist"; exit 1)
docker run -v $(abs_path ${md_source}):/source/source.md -v $(pwd)/output:/output -it --rm doc_converters:latest md_to_pdf
+9
View File
@@ -0,0 +1,9 @@
#!/bin/bash -e
results=${1:?path to kube-bench json results is a required argument}
test_helpers=${2:?path to kube-bench test_helpers scripts is a required argument}
[ -f ${results} ] || (echo "file:'${results}' does not exist"; exit 1)
[ -d ${test_helpers} ] || (echo "dir: '${test_helpers}' not a valid directory"; exit 1)
docker run -v${results}:/source/results.json -v ${test_helpers}:/test_helpers -it --rm doc_converters:latest results_to_md
+18
View File
@@ -0,0 +1,18 @@
#!/bin/bash -e
usage() {
echo -n "[command] [command_options]
commands:
results_to_md: take json output from kube-bench as source and outputs markdown
options:
-s, --source source json from kube-bench default: /source/results.json
"
}
if [[ $# -eq 0 ]]; then
usage
exit 2
fi
scripts/${1}.sh
+6
View File
@@ -0,0 +1,6 @@
#!/bin/bash -e
md_source="/source/source.md"
pandoc -s --template="templates/default.html" -f markdown-smart --toc -c css/style-portrait.css "${md_source}" -o "source.html"
python3 -m weasyprint source.html /output/output.pdf
+117
View File
@@ -0,0 +1,117 @@
results_file="${1:-/source/results.json}"
test_helpers="${2:-/test_helpers}"
get_ids() {
jq -r .id ${results_file} | sort -n
}
get_id_text() {
id=${1}
jq -r --arg id "${id}" 'select(.id==$id) | .text' ${results_file}
}
get_section_ids() {
id=${1}
jq -r --arg id "${id}" 'select(.id==$id) | .tests[].section' ${results_file}
}
get_section_desc() {
id=${1}
section=${2}
jq -r --arg id "${id}" --arg section "${section}" 'select(.id==$id).tests[] | select(.section==$section).desc' ${results_file}
}
get_tests() {
id=${1}
section=${2}
jq -r --arg id "${id}" --arg section "${section}" 'select(.id==$id).tests[] | select(.section==$section).results[].test_number' ${results_file}
}
get_test() {
id=${1}
section=${2}
test_number=${3}
jq -r --arg id "${id}" --arg section "${section}" --arg test_number "${test_number}" 'select(.id==$id).tests[] | select(.section==$section).results[] | select(.test_number==$test_number)' ${results_file}
}
cat headers/header-2.3.5.md
for id in $(get_ids); do
echo "## ${id} $(get_id_text ${id})"
for section in $(get_section_ids ${id}); do
echo "### ${section} $(get_section_desc ${id} ${section})"
echo
for test in $(get_tests ${id} ${section}); do
result=$(get_test ${id} ${section} ${test})
test_desc=$(echo ${result} | jq -r '.test_desc')
audit=$(echo ${result} | jq -r '.audit')
audit_config=$(echo ${result} | jq -r '.AuditConfig')
actual_value=$(echo ${result} | jq -r '.actual_value')
type=$(echo ${result} | jq -r '.type')
status=$(echo ${result} | jq -r '.status')
remediation=$(echo ${result} | jq -r '.remediation')
expected_result=$(echo ${result} | jq -r '.expected_result')
echo "#### ${test} ${test_desc}"
echo
if [ "${type}" = "skip" ]; then
echo "**Result:** Not Applicable"
echo
else
echo "**Result:** ${status}"
echo
fi
if [ ! -z "${remediation}" ]; then
echo "**Remediation:**"
echo "${remediation}"
echo
fi
if [ ! -z "${audit}" ] && [ ${status} != "INFO" ]; then
if [[ ${audit} =~ "test_helpers" ]]; then
audit_script=$(basename ${audit})
test_helper="${test_helpers}/${audit_script}"
echo "**Audit Script:** ${audit_script}"
echo
echo '```'
cat "${test_helper}"
echo '```'
echo
echo "**Audit Execution:**"
echo
echo '```'
echo "./${audit_script} $(echo ${audit} | awk '{print $2}')"
echo '```'
echo
else
echo "**Audit:**"
echo
echo '```'
echo "${audit}"
echo '```'
echo
fi
fi
if [ ! -z "${audit_config}" ] && [ ${status} != "INFO" ]; then
echo "**Audit Config:**"
echo
echo '```'
echo "${audit_config}"
echo '```'
echo
fi
if [ ! -z "${actual_value}" ] && [ ${status} != "PASS" ]; then
echo "**Returned Value**:"
echo
echo "\`${actual_value}\`"
echo
fi
if [ ! -z "${expected_result}" ]; then
echo "**Expected result**:"
echo
echo '```'
echo ${expected_result}
echo '```'
echo
fi
done
done
done
+61
View File
@@ -0,0 +1,61 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="$lang$" xml:lang="$lang$"$if(dir)$ dir="$dir$"$endif$>
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
$for(author-meta)$
<meta name="author" content="$author-meta$" />
$endfor$
$if(date-meta)$
<meta name="dcterms.date" content="$date-meta$" />
$endif$
$if(keywords)$
<meta name="keywords" content="$for(keywords)$$keywords$$sep$, $endfor$" />
$endif$
<title>$if(title-prefix)$$title-prefix$ $endif$$pagetitle$</title>
$for(css)$
<link rel="stylesheet" href="$css$" />
$endfor$
$if(math)$
$math$
$endif$
$for(header-includes)$
$header-includes$
$endfor$
</head>
<body>
$for(include-before)$
$include-before$
$endfor$
$if(title)$
<header id="title-block-header">
<h1 class="title">$title$</h1>
$if(subtitle)$
<p class="subtitle">$subtitle$</p>
$endif$
<div id="header_bottom_text">
$for(author)$
<p class="author">$author$</p>
$endfor$
$if(email)$
<p class="email">$email$</p>
$endif$
$if(date)$
<p class="date">$date$</p>
$endif$
</div>
</header>
$endif$
$if(toc)$
<nav id="$idprefix$TOC">
<div id="contentsbox"><p>Contents</p></div>
$table-of-contents$
</nav>
$endif$
$body$
$for(include-after)$
$include-after$
$endfor$
</body>
</html>