Skip to content

Commit c8d8ba1

Browse files
committed
Use Data templates to pull CVE feed
- Pull JSON blob from queried issues - Use shortcode to generate HTML table - Make JSON blob accessible as static file - Added static file generator for cve feed - Update makefile to use the static file generator Co-authored-by: Neha Lohia <[email protected]> - Update Netlify command
1 parent d2de85c commit c8d8ba1

File tree

6 files changed

+52
-8
lines changed

6 files changed

+52
-8
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,8 @@ node_modules/
3838
# Generated files when building with make container-build
3939
.config/
4040
.npm/
41+
42+
#Generated CVE feed -- In case of issues fetching content
43+
# from bucket please uncomment below line and generate
44+
# official cve feed json blob with scripts/security/gen-cve-feed.sh
45+
static/security/

Makefile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ CCEND=\033[0m
1919
help: ## Show this help.
2020
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
2121

22+
gen-cve-feed: ## Generates content from GCS bucket with official cve data.
23+
scripts/security/gen-cve-feed.sh
24+
2225
module-check: ## Check if all of the required submodules are correctly initialized.
2326
@git submodule status --recursive | awk '/^[+-]/ {err = 1; printf "\033[31mWARNING\033[0m Submodule not initialized: \033[34m%s\033[0m\n",$$2} END { if (err != 0) print "You need to run \033[32mmake module-init\033[0m to initialize missing modules first"; exit err }' 1>&2
2427

@@ -28,10 +31,10 @@ module-init: ## Initialize required submodules.
2831

2932
all: build ## Build site with production settings and put deliverables in ./public
3033

31-
build: module-check ## Build site with non-production settings and put deliverables in ./public
34+
build: module-check gen-cve-feed## Build site with non-production settings and put deliverables in ./public
3235
hugo --minify --environment development
3336

34-
build-preview: module-check ## Build site with drafts and future posts enabled
37+
build-preview: module-check gen-cve-feed ## Build site with drafts and future posts enabled
3538
hugo --buildDrafts --buildFuture --environment preview
3639

3740
deploy-preview: ## Deploy preview site via netlify
@@ -43,11 +46,11 @@ functions-build:
4346
check-headers-file:
4447
scripts/check-headers-file.sh
4548

46-
production-build: module-check ## Build the production site and ensure that noindex headers aren't added
49+
production-build: module-check gen-cve-feed ## Build the production site and ensure that noindex headers aren't added
4750
hugo --minify --environment production
4851
HUGO_ENV=production $(MAKE) check-headers-file
4952

50-
non-production-build: module-check ## Build the non-production site, which adds noindex headers to prevent indexing
53+
non-production-build: module-check gen-cve-feed ## Build the non-production site, which adds noindex headers to prevent indexing
5154
hugo --enableGitInfo --environment nonprod
5255

5356
serve: module-check ## Boot the development server.
@@ -65,6 +68,9 @@ docker-serve:
6568
@echo -e "$(CCRED)**** The use of docker-serve is deprecated. Use container-serve instead. ****$(CCEND)"
6669
$(MAKE) container-serve
6770

71+
container-gen-cve-feed: ## Generates official cve feed from external sources within a container (equiv to gen-cve-feed).
72+
$(CONTAINER_RUN) $(CONTAINER_IMAGE) scripts/security/gen-cve-feed.sh
73+
6874
container-image: ## Build a container image for the preview of the website
6975
$(CONTAINER_ENGINE) build . \
7076
--network=host \

content/en/docs/reference/issues-security/issues.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,12 @@ Work on Kubernetes code and public issues are tracked using [GitHub Issues](http
1111
* [CVE-related issues](https://github.com/kubernetes/kubernetes/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3Aarea%2Fsecurity+in%3Atitle+CVE)
1212

1313
Security-related announcements are sent to the [[email protected]](https://groups.google.com/forum/#!forum/kubernetes-security-announce) mailing list.
14+
15+
{{< issues-security >}}
16+
17+
<!-- | CVE ID | Summary | Issue details |
18+
| ----------- | ----------- | --------- |
19+
| [CVE-2021-25741](https://www.cve.org/CVERecord?id=CVE-2021-25741) | Symlink Exchange Can Allow Host Filesystem Access | [#104980](https://github.com/kubernetes/kubernetes/issues/104980) |
20+
| [CVE-2020-8565](https://www.cve.org/CVERecord?id=CVE-2020-8565) | Incomplete fix for CVE-2019-11250 allows for token leak in logs when logLevel >= 9 | [#95623](https://github.com/kubernetes/kubernetes/issues/95623) | -->
21+
22+
Security-related announcements are sent to the [[email protected]](https://groups.google.com/forum/#!forum/kubernetes-security-announce) mailing list.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<table>
2+
<thead>
3+
<tr>
4+
<th>CVE ID</th>
5+
<th>Summary</th>
6+
<th>Issue Details</th>
7+
</tr>
8+
</thead>
9+
<tbody>
10+
{{ range $issues := getJSON "static/security/official-cve-feed.json" }}
11+
<tr>
12+
<td><a href="{{ .cve_url }}">{{ .cve_id }}</a></td>
13+
<td>{{ .summary }}</td>
14+
<td><a href="{{ .issue_url }}">#{{ .number }}</a></td>
15+
</tr>
16+
{{ end }}
17+
</tbody>
18+
</table>

netlify.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# DO NOT REMOVE THIS (contact @kubernetes/sig-docs-leads)
55
publish = "public"
66
functions = "functions"
7-
command = "git submodule update --init --recursive --depth 1 && make non-production-build"
7+
command = "git submodule update --init --recursive --depth 1 && scripts/security/gen-cve-feed.sh && make non-production-build"
88

99
[build.environment]
1010
NODE_VERSION = "10.20.0"
@@ -17,13 +17,13 @@ HUGO_ENV = "production"
1717
HUGO_ENABLEGITINFO = "true"
1818

1919
[context.deploy-preview]
20-
command = "git submodule update --init --recursive --depth 1 && make deploy-preview"
20+
command = "git submodule update --init --recursive --depth 1 && scripts/security/gen-cve-feed.sh && make deploy-preview"
2121

2222
[context.branch-deploy]
23-
command = "git submodule update --init --recursive --depth 1 && make non-production-build"
23+
command = "git submodule update --init --recursive --depth 1 && scripts/security/gen-cve-feed.sh && make non-production-build"
2424

2525
[context.main]
2626
# This context is triggered by the `main` branch and allows search indexing
2727
# DO NOT REMOVE THIS (contact @kubernetes/sig-docs-leads)
2828
publish = "public"
29-
command = "git submodule update --init --recursive --depth 1 && make production-build"
29+
command = "git submodule update --init --recursive --depth 1 && scripts/security/gen-cve-feed.sh && make production-build"

scripts/security/gen-cve-feed.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
3+
mkdir -p static/security/
4+
touch static/security/official-cve-feed.json
5+
#TODO: this will be updated with k8s-gcs-bucket
6+
wget -O static/security/official-cve-feed.json "https://storage.googleapis.com/fake-test-cve-feed-kep-3203/official-cve-feed.json"

0 commit comments

Comments
 (0)