Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion application/defs/osib_defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def paths_to_osib(
attributes=Node_attributes(
sources_i18n={
Lang("en"): _Source(
name="Open Web Application Security Project",
name="Open Worldwide Application Security Project",
source="https://owasp.org",
)
}
Expand Down
2 changes: 1 addition & 1 deletion application/frontend/src/pages/MyOpenCRE/MyOpenCRE.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
}

.myopencre-upload {
margin-top: 1.5rem;
margin-top: 3rem;
}

.myopencre-disabled {
Expand Down
27 changes: 4 additions & 23 deletions application/frontend/src/pages/MyOpenCRE/MyOpenCRE.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ export const MyOpenCRE = () => {

const downloadCreCsv = async () => {
try {
const response = await fetch(`${apiUrl}/cre_csv`, {
const baseUrl = apiUrl || window.location.origin;
const backendUrl = baseUrl.includes('localhost') ? 'http://127.0.0.1:5000' : baseUrl;

const response = await fetch(`${backendUrl}/cre_csv`, {
method: 'GET',
headers: { Accept: 'text/csv' },
});
Expand All @@ -46,25 +49,6 @@ export const MyOpenCRE = () => {
}
};

const downloadTemplate = () => {
const headers = ['standard_name', 'standard_section', 'cre_id', 'notes'];

const csvContent = headers.join(',') + '\n';

const blob = new Blob([csvContent], {
type: 'text/csv;charset=utf-8;',
});

const url = URL.createObjectURL(blob);
const link = document.createElement('a');

link.href = url;
link.setAttribute('download', 'myopencre_mapping_template.csv');
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
};

/* ------------------ FILE SELECTION ------------------ */

const onFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
Expand Down Expand Up @@ -144,9 +128,6 @@ export const MyOpenCRE = () => {
<Button primary onClick={downloadCreCsv}>
Download CRE Catalogue (CSV)
</Button>
<Button secondary onClick={downloadTemplate} style={{ marginLeft: '1rem' }}>
Download Mapping Template (CSV)
</Button>
</div>

<div className="myopencre-section myopencre-upload">
Expand Down
2 changes: 1 addition & 1 deletion application/frontend/www/bundle.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions application/tests/data/osib_example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ schema: v0.90
date: 2021/11/04
children:
"OWASP":
aliases: ["Open Web Application Security Project", "owasp"]
aliases: ["Open Worldwide Application Security Project", "owasp"]
attributes:
sources_i18n:
en:
name: "Open Web Application Security Project&reg; (OWASP)"
name: "Open Worldwide Application Security Project&reg; (OWASP)"
children:
"ZAP":
attributes:
Expand Down
4 changes: 2 additions & 2 deletions application/tests/osib_defs_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@
# attributes=Node_attributes(
# sources_i18n={
# Lang("en"): _Source(
# name="Open Web Application Security Project",
# name="Open Worldwide Application Security Project",
# source="https://owasp.org",
# )
# }
Expand Down Expand Up @@ -326,7 +326,7 @@
# attributes=defs.Node_attributes(
# sources_i18n={
# defs.Lang("en"): defs._Source(
# name="Open Web Application Security Project",
# name="Open Worldwide Application Security Project",
# source="https://owasp.org",
# )
# }
Expand Down
6 changes: 3 additions & 3 deletions application/utils/spreadsheet_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ def validate_import_csv_rows(rows: List[Dict[str, Any]]) -> List[Dict[str, Any]]

headers = list(rows[0].keys())

if not headers or len(headers) < 2:
raise ValueError("Invalid CSV format or missing header row")
if not headers:
raise ValueError("CSV header row is missing")

if not any(h.startswith("CRE") for h in headers):
raise ValueError("At least one CRE column is required")
Expand Down Expand Up @@ -203,7 +203,7 @@ def parse_export_format(lfile: List[Dict[str, Any]]) -> Dict[str, List[defs.Docu
Given: a spreadsheet written by prepare_spreadsheet()
return a list of CRE docs
"""
validated_rows = validate_import_csv_rows(lfile)
validated_rows = validate_export_csv_rows(lfile)
cres: Dict[str, defs.CRE] = {}
standards: Dict[str, Dict[str, defs.Standard]] = {}
documents: Dict[str, List[defs.Document]] = {}
Expand Down
2 changes: 1 addition & 1 deletion migrations/versions/7a17989aa1e3_first_migration.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""First Migration

Revision ID: 7a17989aa1e3
Revises:
Revises:
Create Date: 2021-08-31 19:23:49.227719

"""
Expand Down