Skip to content

Commit c03df58

Browse files
Merge branch 'main' into gsocmodule_C_week_5
2 parents fe71108 + 7d0634e commit c03df58

9 files changed

Lines changed: 26 additions & 10 deletions

File tree

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ Vagrantfile
4848

4949
### conventions ###
5050
venv/
51+
.venv/
5152
venv-*/
5253
v/
5354

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
FROM node:lts as build
22
LABEL org.opencontainers.image.source = "https://github.com/OWASP/OpenCRE"
33
WORKDIR /code
4+
RUN apt-get update && apt-get install -y chromium
45
COPY . /code
56
RUN yarn install && yarn build
67

application/frontend/src/pages/Explorer/visuals/force-graph/forceGraph.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const ExplorerForceGraph = () => {
3131
fullLoadProgress,
3232
dataLoadError,
3333
} = useDataStore();
34-
const fgRef = useRef<ForceGraphMethods>();
34+
const fgRef = useRef<ForceGraphMethods | undefined>(undefined);
3535
// ADDING STATE FOR FILTERING LOGIC
3636
const [filterTypeA, setFilterTypeA] = useState('');
3737
const [filterTypeB, setFilterTypeB] = useState('');

application/frontend/src/pages/GapAnalysis/GapAnalysis.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export const GapAnalysis = () => {
127127
const [loadingGA, setLoadingGA] = useState<boolean>(false);
128128
const [error, setError] = useState<string | null | object>(null);
129129
const { apiUrl } = useEnvironment();
130-
const timerIdRef = useRef<NodeJS.Timer>();
130+
const timerIdRef = useRef<ReturnType<typeof setInterval> | undefined>(undefined);
131131

132132
useEffect(() => {
133133
const fetchData = async () => {
@@ -173,7 +173,9 @@ export const GapAnalysis = () => {
173173
timerIdRef.current = setInterval(pollingCallback, 10000);
174174
};
175175
const stopPolling = () => {
176-
clearInterval(timerIdRef.current);
176+
if (timerIdRef.current !== undefined) {
177+
clearInterval(timerIdRef.current);
178+
}
177179
};
178180

179181
if (gaJob) {

application/frontend/src/pages/chatbot/chatbot.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export const Chatbot = () => {
105105

106106
function processResponse(response: string) {
107107
const responses = response.split('```');
108-
const res: JSX.Element[] = [];
108+
const res: React.ReactElement[] = [];
109109

110110
responses.forEach((txt, i) => {
111111
if (i % 2 === 0) {

application/frontend/src/routes.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ReactNode } from 'react';
1+
import { ElementType } from 'react';
22

33
import {
44
BROWSEROOT,
@@ -34,7 +34,7 @@ const ExplorerForceGraphWithLayout = withExplorerLayout(ExplorerForceGraph);
3434

3535
export interface IRoute {
3636
path: string;
37-
component: ReactNode | ReactNode[];
37+
component: ElementType;
3838
showFilter: boolean;
3939
}
4040
export interface Capabilities {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"build": "webpack --config webpack.prod.js",
99
"start": "webpack serve",
1010
"test:e2e": "jest",
11-
"postinstall": "del-cli node_modules/@types/react-dom/node_modules/@types && del-cli node_modules/webpack/types.d.ts"
11+
"postinstall": "del-cli node_modules/@types/react-dom/node_modules/@types && del-cli node_modules/webpack/types.d.ts && del-cli node_modules/@types/minimatch"
1212
},
1313
"keywords": [],
1414
"author": "Craig Knott",

scripts/prod-docker-entrypoint.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,19 @@
22

33
export INSECURE_REQUESTS=1
44
export FLASK_CONFIG="production"
5-
export FLASK_APP=`pwd`/cre.py
6-
flask db upgrade
5+
export FLASK_APP=`pwd`/cre.py
6+
flask db upgrade heads
7+
python - <<'PY'
8+
import sqlite3
9+
10+
db_path = "/code/standards_cache.sqlite"
11+
conn = sqlite3.connect(db_path)
12+
for table in ("cre", "node"):
13+
cols = {row[1] for row in conn.execute(f"PRAGMA table_info({table})")}
14+
if "document_metadata" not in cols:
15+
conn.execute(f"ALTER TABLE {table} ADD COLUMN document_metadata JSON")
16+
conn.commit()
17+
conn.close()
18+
PY
719
python /code/cre.py --upstream_sync
820
gunicorn cre:app -b :5000 --timeout 90

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616
"esModuleInterop": true
1717
},
1818
"include": ["**/*.ts", "**/*.tsx", "**/*.js", "src/**/*"],
19-
"exclude": ["venv", "dist", "node_modules", "build", "scripts"]
19+
"exclude": ["venv", "dist", "node_modules", "build", "scripts", "application/frontend/www"]
2020
}

0 commit comments

Comments
 (0)