Skip to content

Commit f2871f6

Browse files
feat(myopencre): enable CSV download of all CREs
1 parent 7a33020 commit f2871f6

File tree

14 files changed

+696
-231
lines changed

14 files changed

+696
-231
lines changed

.python-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.11
1+
3.11.9

application/defs/osib_defs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ def paths_to_osib(
347347
attributes=Node_attributes(
348348
sources_i18n={
349349
Lang("en"): _Source(
350-
name="Open Worldwide Application Security Project",
350+
name="Open Web Application Security Project",
351351
source="https://owasp.org",
352352
)
353353
}

application/frontend/src/pages/MyOpenCRE/MyOpenCRE.scss

Whitespace-only changes.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import React from 'react';
2+
import { Button, Container, Header } from 'semantic-ui-react';
3+
4+
import { useEnvironment } from '../../hooks';
5+
6+
export const MyOpenCRE = () => {
7+
const { apiUrl } = useEnvironment();
8+
// console.log('API URL:', apiUrl);
9+
10+
const downloadCreCsv = async () => {
11+
try {
12+
const baseUrl = apiUrl || window.location.origin;
13+
14+
const backendUrl = baseUrl.includes('localhost') ? 'http://127.0.0.1:5000' : baseUrl;
15+
16+
const response = await fetch(`${backendUrl}/cre_csv`, {
17+
method: 'GET',
18+
headers: {
19+
Accept: 'text/csv',
20+
},
21+
});
22+
23+
if (!response.ok) {
24+
throw new Error(`HTTP error ${response.status}`);
25+
}
26+
27+
const blob = await response.blob();
28+
const url = window.URL.createObjectURL(blob);
29+
30+
const link = document.createElement('a');
31+
link.href = url;
32+
link.download = 'opencre-cre-mapping.csv';
33+
document.body.appendChild(link);
34+
link.click();
35+
36+
document.body.removeChild(link);
37+
window.URL.revokeObjectURL(url);
38+
} catch (err) {
39+
console.error('CSV download failed:', err);
40+
alert('Failed to download CRE CSV');
41+
}
42+
};
43+
44+
return (
45+
<Container style={{ marginTop: '3rem' }}>
46+
<Header as="h1">MyOpenCRE</Header>
47+
48+
<p>
49+
MyOpenCRE allows you to map your own security standard (e.g. SOC2) to OpenCRE Common Requirements
50+
using a CSV spreadsheet.
51+
</p>
52+
53+
<p>
54+
Start by downloading the mapping template below, fill it with your standard’s controls, and map them
55+
to CRE IDs.
56+
</p>
57+
58+
<Button primary onClick={downloadCreCsv}>
59+
Download CRE Catalogue (CSV)
60+
</Button>
61+
</Container>
62+
);
63+
};

application/frontend/src/pages/Search/components/SearchBar.scss

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
color: var(--muted-foreground);
2424
height: 1rem;
2525
width: 1rem;
26-
pointer-events: none;
27-
z-index: 1;
2826
}
2927

3028
input {

application/frontend/src/routes.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { ExplorerCircles } from './pages/Explorer/visuals/circles/circles';
2121
import { ExplorerForceGraph } from './pages/Explorer/visuals/force-graph/forceGraph';
2222
import { GapAnalysis } from './pages/GapAnalysis/GapAnalysis';
2323
import { MembershipRequired } from './pages/MembershipRequired/MembershipRequired';
24+
import { MyOpenCRE } from './pages/MyOpenCRE/MyOpenCRE';
2425
import { SearchName } from './pages/Search/SearchName';
2526
import { StandardSection } from './pages/Standard/StandardSection';
2627

@@ -31,6 +32,12 @@ export interface IRoute {
3132
}
3233

3334
export const ROUTES: IRoute[] = [
35+
{
36+
path: '/myopencre',
37+
component: MyOpenCRE,
38+
showFilter: false,
39+
},
40+
3441
{
3542
path: INDEX,
3643
component: SearchPage,

application/frontend/src/scaffolding/Header/Header.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Button } from 'semantic-ui-react';
77

88
import { ClearFilterButton } from '../../components/FilterButton/FilterButton';
99
import { useLocationFromOutsideRoute } from '../../hooks/useLocationFromOutsideRoute';
10+
import { MyOpenCRE } from '../../pages/MyOpenCRE/MyOpenCRE';
1011
import { SearchBar } from '../../pages/Search/components/SearchBar';
1112

1213
export const Header = () => {
@@ -49,6 +50,9 @@ export const Header = () => {
4950
<a href="/explorer" className="nav-link">
5051
Explorer
5152
</a>
53+
<Link to="/myopencre" className="nav-link">
54+
MyOpenCRE
55+
</Link>
5256
</div>
5357

5458
<div>
@@ -137,6 +141,9 @@ export const Header = () => {
137141
<a href="/explorer" className="nav-link" onClick={closeMobileMenu}>
138142
Explorer
139143
</a>
144+
<a href="/myopencre" className="nav-link" onClick={MyOpenCRE}>
145+
MyOpenCRE
146+
</a>
140147
</div>
141148

142149
<div className="mobile-auth">

application/frontend/src/scaffolding/Header/header.scss

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -301,16 +301,3 @@
301301
display: block;
302302
}
303303
}
304-
305-
.sr-only {
306-
position: absolute;
307-
width: 1px;
308-
height: 1px;
309-
padding: 0;
310-
margin: -1px;
311-
overflow: hidden;
312-
clip: rect(0, 0, 0, 0);
313-
clip-path: inset(50%);
314-
white-space: nowrap;
315-
border: 0;
316-
}

application/frontend/www/bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

application/tests/data/osib_example.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ schema: v0.90
44
date: 2021/11/04
55
children:
66
"OWASP":
7-
aliases: ["Open Worldwide Application Security Project", "owasp"]
7+
aliases: ["Open Web Application Security Project", "owasp"]
88
attributes:
99
sources_i18n:
1010
en:
11-
name: "Open Worldwide Application Security Project&reg; (OWASP)"
11+
name: "Open Web Application Security Project&reg; (OWASP)"
1212
children:
1313
"ZAP":
1414
attributes:

0 commit comments

Comments
 (0)