Skip to content
This repository was archived by the owner on Apr 21, 2026. It is now read-only.

Commit 600cb77

Browse files
committed
Add page for scanner examples, parse examples directory. Fix missing iteration keys. Fix wrong class attributes (react convention: className).
1 parent a5e0252 commit 600cb77

9 files changed

Lines changed: 148 additions & 65 deletions

File tree

gatsby-config.js

Lines changed: 16 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,6 @@
44
* See: https://www.gatsbyjs.org/docs/gatsby-config/
55
*/
66

7-
const scannerRepos = [
8-
{
9-
name: 'Amass',
10-
directory: 'amass'
11-
},
12-
{
13-
name: 'kube-hunter',
14-
directory: 'kube-hunter'
15-
},
16-
{
17-
name: 'Nikto',
18-
directory: 'nikto'
19-
},
20-
{
21-
name: 'Nmap',
22-
directory: 'nmap'
23-
},
24-
{
25-
name: 'SSH',
26-
directory: 'ssh_scan'
27-
},
28-
{
29-
name: 'SSLyze',
30-
directory: 'sslyze'
31-
},
32-
{
33-
name: 'Trivy',
34-
directory: 'trivy'
35-
},
36-
{
37-
name: 'WPScan',
38-
directory: 'wpscan'
39-
},
40-
{
41-
name: 'ZAP',
42-
directory: 'zap'
43-
}
44-
];
45-
467
module.exports = {
478
siteMetadata: {
489
title: `secureCodeBox`,
@@ -133,16 +94,21 @@ module.exports = {
13394
name: 'images',
13495
},
13596
},
136-
...scannerRepos.map(({ name, directory }) => {
137-
return {
138-
resolve: `gatsby-source-git`,
139-
options: {
140-
name: name,
141-
remote: `https://github.com/secureCodeBox/secureCodeBox-v2-alpha`,
142-
branch: `master`,
143-
patterns: `scanners/${directory}/README.md`,
144-
},
145-
};
146-
}),
97+
{
98+
resolve: `gatsby-source-git`,
99+
options: {
100+
name: `secureCodeBox-v2-alpha`,
101+
remote: `https://github.com/secureCodeBox/secureCodeBox-v2-alpha`,
102+
branch: `master`,
103+
patterns: `scanners`,
104+
},
105+
},
106+
{
107+
resolve: `gatsby-source-filesystem`,
108+
options: {
109+
name: `scanners`,
110+
path: `${__dirname}/.cache/gatsby-source-git/secureCodeBox-v2-alpha/scanners`,
111+
}
112+
}
147113
],
148114
};

gatsby-node.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const path = require("path");
2+
const fs = require("fs");
23

34
// Create pages from markdown files
45
exports.createPages = ({ graphql, actions }) => {
@@ -52,6 +53,16 @@ exports.createPages = ({ graphql, actions }) => {
5253
}
5354
}
5455
}
56+
scannerExamples: allFile(filter: {absolutePath: {regex: "/scanners/(.*)/examples/"}, extension: {eq: "yaml"}}) {
57+
edges {
58+
node {
59+
id
60+
name
61+
extension
62+
dir
63+
}
64+
}
65+
}
5566
persistenceProvider: allMarkdownRemark(
5667
filter: { fileAbsolutePath: { regex: "/integrations/persistence-provider/" } }
5768
) {
@@ -97,6 +108,15 @@ exports.createPages = ({ graphql, actions }) => {
97108
id: node.id
98109
}
99110
});
111+
112+
const examplesComponent = path.resolve("src/templates/scannerExamples.js");
113+
createPage({
114+
path: `integrations/${node.frontmatter.path}/examples`,
115+
component: examplesComponent,
116+
context: {
117+
basePath: `/${node.frontmatter.path}/examples/`
118+
}
119+
});
100120
});
101121
result.data.persistenceProvider.edges.forEach(({ node }) => {
102122
const component = path.resolve("src/templates/integration.js");
@@ -113,3 +133,15 @@ exports.createPages = ({ graphql, actions }) => {
113133
);
114134
});
115135
};
136+
137+
exports.onCreateNode = ({ node, actions }) => {
138+
const { createNodeField } = actions;
139+
140+
if (node.internal.type === `File` && (node.base === `scan.yaml` || node.base === `findings.yaml`)) {
141+
fs.readFile(node.absolutePath, undefined, (_err, buf) => {
142+
createNodeField({ node, name: `content`, value: buf.toString() });
143+
});
144+
createNodeField({ node, name: `fileName`, value: node.base });
145+
createNodeField({ node, name: `scanTarget`, value: node.relativeDirectory.split('/examples/')[1] });
146+
}
147+
}

package-lock.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"react": "^16.13.1",
2929
"react-burger-menu": "^2.7.0",
3030
"react-dom": "^16.13.1",
31-
"react-helmet": "^6.1.0"
31+
"react-helmet": "^6.1.0",
32+
"react-tabs": "^3.1.1"
3233
},
3334
"devDependencies": {
3435
"node-sass": "^4.14.1",

src/components/BetaAlert.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import React from 'react';
22

33
const BetaAlert = () => (
4-
<div class="alert alert-warning beta-alert" role="alert">
4+
<div className="alert alert-warning beta-alert" role="alert">
55
You are looking at preliminary documentation for secureCodeBox v2 beta. Not what you want? See <a
66
href="https://github.com/secureCodeBox/secureCodeBox/blob/master/README.md"
7-
class="alert-link"
7+
className="alert-link"
88
rel="noreferrer"
99
target="_blank">
1010
latest stable release documentation

src/components/MenuMobile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const MenuMobile = props => {
1919
}}
2020
>
2121
{menuLinks.map(link => (
22-
<Link to={link.link}>{link.name}</Link>
22+
<Link to={link.link} key={link.name}>{link.name}</Link>
2323
))}
2424
</Menu>
2525
);

src/pages/integrations/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ const Integrations = props => {
3131
<div className="col-12">
3232
<h2 className="title-3 text-dark mb-2">Scanner</h2>
3333
</div>
34-
{scanner.map(edge => (
34+
{scanner.map((edge, index) => (
3535
<div
36-
key={edge.node.id}
36+
key={index}
3737
className="col-12 col-md-6 col-lg-6 col-sm-12 mb-2 no-highlight"
3838
>
3939
<Link to={edge.node.frontmatter.path}>
@@ -43,8 +43,8 @@ const Integrations = props => {
4343
className="scanner-icon"
4444
src={withPrefix(
4545
'/integrationIcons/' +
46-
edge.node.frontmatter.title +
47-
'.svg'
46+
edge.node.frontmatter.title +
47+
'.svg'
4848
)}
4949
alt="scanner icon"
5050
></img>
@@ -79,8 +79,8 @@ const Integrations = props => {
7979
className="scanner-icon"
8080
src={withPrefix(
8181
'/integrationIcons/' +
82-
edge.node.frontmatter.title +
83-
'.svg'
82+
edge.node.frontmatter.title +
83+
'.svg'
8484
)}
8585
alt="persistence provider icon"
8686
></img>

src/templates/integration.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ const Integration = props => {
1313
<div className="sidebar-wrapper">
1414
<nav className="sidebar">
1515
<h1 className="sidebar-header">Scanner</h1>
16-
<ul class="list-unstyled components">
16+
<ul className="list-unstyled components">
1717
{scanner.map(scanner => (
18-
<li>
18+
<li key={scanner.node.frontmatter.title}>
1919
<Link
2020
to={`/integrations/${scanner.node.frontmatter.path}`}
2121
activeClassName="active-Link"
@@ -26,9 +26,9 @@ const Integration = props => {
2626
))}
2727
</ul>
2828
<h1 className="sidebar-header">Persistence provider</h1>
29-
<ul class="list-unstyled components">
29+
<ul className="list-unstyled components">
3030
{persistenceProvider.map(persistenceProvider => (
31-
<li>
31+
<li key={persistenceProvider.node.frontmatter.title}>
3232
<Link
3333
to={`/integrations/${persistenceProvider.node.frontmatter.path}`}
3434
activeClassName="active-Link"
@@ -41,7 +41,7 @@ const Integration = props => {
4141
</nav>
4242

4343
<div id="content">
44-
<div class="container-fluid" id="integration-doc">
44+
<div className="container-fluid" id="integration-doc">
4545
<h1 className="title">{title}</h1>
4646
<div
4747
className="content"

src/templates/scannerExamples.js

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import React from "react";
2+
import { graphql } from "gatsby";
3+
import Layout from "../components/Layout";
4+
import { Tab, Tabs, TabList, TabPanel } from 'react-tabs';
5+
import 'react-tabs/style/react-tabs.css';
6+
7+
const ScannerExamples = props => {
8+
const path = `${props.path.substring(13)}/`;
9+
const examples = props.data.examples.nodes;
10+
const targets = [];
11+
12+
examples.forEach(example => {
13+
if (!targets.includes(example.fields.scanTarget)) {
14+
targets.push(example.fields.scanTarget);
15+
}
16+
});
17+
18+
return (
19+
<Layout bodyClass="integration">
20+
<div className="container-fluid">
21+
<div id="content">
22+
<h1 className="title">Examples for {path.split('/')[2]}</h1>
23+
24+
<Tabs>
25+
<TabList>
26+
{targets.map(target => (<Tab key={target}>{target}</Tab>))}
27+
</TabList>
28+
{targets.map(target => (<TabPanel key={target}>
29+
<Tabs>
30+
<TabList>
31+
{examples.filter(example => example.fields.scanTarget === target).map((example, index) => (
32+
<Tab key={index}>{example.fields.fileName}</Tab>
33+
))}
34+
</TabList>
35+
36+
{examples.filter(example => example.fields.scanTarget === target).map((example, index) => (
37+
<TabPanel key={index}>
38+
<pre><code>{example.fields.content}</code></pre>
39+
</TabPanel>
40+
))}
41+
</Tabs>
42+
</TabPanel>))}
43+
</Tabs>
44+
</div>
45+
</div>
46+
</Layout>
47+
);
48+
};
49+
50+
export const query = graphql`
51+
query($basePath: String!) {
52+
examples: allFile(filter: {absolutePath: {regex: $basePath}, extension: {eq: "yaml"}}) {
53+
edges {
54+
node {
55+
base
56+
relativeDirectory
57+
}
58+
}
59+
nodes {
60+
fields {
61+
content
62+
fileName
63+
scanTarget
64+
}
65+
}
66+
}
67+
}
68+
`;
69+
70+
export default ScannerExamples;

0 commit comments

Comments
 (0)