-
Notifications
You must be signed in to change notification settings - Fork 40
Staging #206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Staging #206
Changes from all commits
5fb6d51
b652d8b
a80b174
ec11a2a
ecbef2a
e7c8d76
706b487
fbe93b2
3d0ad9e
98f3cb6
56ce407
d80b8f3
9920291
59288b3
f326aff
89710a4
e5bd783
4a8e27f
f4d5bb3
bc035f1
c0c7c70
7e3a47b
5967b96
c3d8cbb
d30cfe9
0d00a00
fe926f1
ffec1fe
0180c14
74fff0a
5ccad75
ff67b5d
8f85cdd
24d9943
1426b64
6c72394
96e29aa
e447054
47dbf29
d35231f
6d966cf
416558c
938dec2
679b236
d1de315
5626cef
f03f71a
5ed94e9
2659794
a7062a7
2c594cd
8b2b92c
4735ebc
fb1a044
0d6d01f
aac5628
a041e6b
b339c9a
0876b0e
e20d811
51001e4
08a65f7
6a3af9a
f574f45
9abe0d8
23eaec2
5afa2ea
00f26d3
140c1cd
bbea97d
c1088e8
a24fdff
f684610
cca770a
8dd162b
bb54cec
b4428ef
34d00ff
0c2cea7
f66f7e7
d8439ee
19b2c7e
b69af5b
ce859ce
fb34075
9ff7209
63507b0
abbb6e2
1042013
290d430
fe1efe9
9699aee
9f10de2
3e00c72
5f8cf6d
9a10a98
ff49633
1701a65
b74c5b8
3b01620
51e8366
9e01868
98c709e
2ad1bf6
83f9167
0c51b37
9060837
58538cd
fd56661
342b836
5ce70a0
271e066
a08ed4d
236c048
4f4a6ec
a174b12
c3f9fa2
ea49177
e2ea644
64ffa80
93562a7
3605943
7272707
da92572
7b99256
5ea436e
7803c05
79ea7c7
3aecebc
ef414af
59563b4
e398242
7091199
086ec9d
beef368
02d5fc6
8369d88
cacb58d
2e24de9
c97250b
f7f7d01
f7a7a62
8123fad
1433065
695f432
984578c
2d39235
b62729a
6dee0df
f87bfce
224b080
9627f10
d578923
52fca1b
3b264f4
9d29138
14421e8
7d73831
d1c0523
e0d6ef3
efa22f0
c286434
fae3c40
873b54b
f4391bf
4b007b1
521e8fe
56053c3
3b224dc
a0b557f
41c7ea8
bb6984f
867b0bf
4e50f50
3456201
56dc83c
bcbae95
c0920ba
9c1533a
01eedde
d2de20c
0323a44
ab0b6b8
d48f176
003f2c2
c5a84be
5802392
f812219
6c11ae7
63df81d
2646e5a
cc09855
ad43d84
e5e1596
6bd66b3
e6d7aef
0add821
59ecdc3
a4ad276
19fcbd6
ed2b374
b36af0a
9a72748
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,41 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
name: Playwright Tests | ||||||||||||||||||||||||||||||||||||||||||||||||||||
on: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
push: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
branches: [ main, staging ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
pull_request: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
branches: [ main, staging ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
jobs: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
test: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
timeout-minutes: 60 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||||||||||||||||||||||
services: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
falkordb: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
image: falkordb/falkordb:latest | ||||||||||||||||||||||||||||||||||||||||||||||||||||
ports: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- 6379:6379 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
steps: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- uses: actions/setup-node@v4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
with: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
node-version: lts/* | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- name: Install dependencies | ||||||||||||||||||||||||||||||||||||||||||||||||||||
run: npm ci | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- name: Install Playwright Browsers | ||||||||||||||||||||||||||||||||||||||||||||||||||||
run: npx playwright install --with-deps | ||||||||||||||||||||||||||||||||||||||||||||||||||||
- name: Set up environment variables and run tests | ||||||||||||||||||||||||||||||||||||||||||||||||||||
env: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
FALKORDB_URL: ${{ secrets.FALKORDB_URL }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
SECRET_TOKEN: ${{ secrets.SECRET_TOKEN }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
NEXT_PUBLIC_MODE: UNLIMITED | ||||||||||||||||||||||||||||||||||||||||||||||||||||
BACKEND_URL: ${{ secrets.BACKEND_URL }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||
npm install | ||||||||||||||||||||||||||||||||||||||||||||||||||||
npm run build | ||||||||||||||||||||||||||||||||||||||||||||||||||||
NEXTAUTH_SECRET=SECRET npm start & npx playwright test --reporter=dot,list | ||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+25
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Several issues in test execution setup
- run: |
- npm install
- npm run build
- NEXTAUTH_SECRET=SECRET npm start & npx playwright test --reporter=dot,list
+ env:
+ NEXTAUTH_SECRET: ${{ secrets.NEXTAUTH_SECRET }}
+ run: |
+ npm run build
+ npm start &
+ echo "Waiting for app to start..."
+ npx wait-on http://localhost:3000
+ npx playwright test --reporter=dot,list 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
- uses: actions/upload-artifact@v4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
if: ${{ !cancelled() }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
with: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
name: playwright-report | ||||||||||||||||||||||||||||||||||||||||||||||||||||
path: playwright-report/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
retention-days: 30 |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -37,4 +37,9 @@ next-env.d.ts | |||||
|
||||||
|
||||||
# vscode | ||||||
/.vscode/ | ||||||
/.vscode/ | ||||||
node_modules/ | ||||||
Comment on lines
+40
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Remove duplicate entries The following entries are duplicates of existing patterns in the file:
Apply this diff to remove the duplicates: -/.vscode/
-node_modules/ 📝 Committable suggestion
Suggested change
|
||||||
/test-results/ | ||||||
/playwright-report/ | ||||||
/blob-report/ | ||||||
/playwright/.cache/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { NextRequest, NextResponse } from "next/server" | ||
import { getEnvVariables } from "../../utils" | ||
|
||
|
||
export async function POST(request: NextRequest, { params }: { params: Promise<{ graph: string }> }) { | ||
|
||
const repo = (await params).graph | ||
const msg = request.nextUrl.searchParams.get('msg') | ||
|
||
try { | ||
|
||
if (!msg) { | ||
throw new Error("Message parameter is required") | ||
} | ||
|
||
const { url, token } = getEnvVariables() | ||
|
||
const result = await fetch(`${url}/chat`, { | ||
method: 'POST', | ||
body: JSON.stringify({ repo, msg }), | ||
headers: { | ||
"Authorization": token, | ||
"Content-Type": 'application/json' | ||
}, | ||
cache: 'no-store' | ||
}) | ||
|
||
if (!result.ok) { | ||
throw new Error(await result.text()) | ||
} | ||
|
||
const json = await result.json() | ||
|
||
return NextResponse.json({ result: json }, { status: 200 }) | ||
Comment on lines
+28
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Improve response handling security The current response handling could expose sensitive information or be vulnerable to large responses:
Implement safer response handling: if (!result.ok) {
- throw new Error(await result.text())
+ const errorText = await result.text()
+ console.error(`Backend error: ${errorText}`)
+ throw new Error('An error occurred while processing your request')
}
+ const contentType = result.headers.get('content-type')
+ if (!contentType?.includes('application/json')) {
+ throw new Error('Invalid response type from backend')
+ }
+
const json = await result.json()
|
||
} catch (err) { | ||
console.error(err) | ||
return NextResponse.json((err as Error).message, { status: 400 }) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,24 +1,45 @@ | ||||||||||||||||||||||||||||||||||
import { FalkorDB, Graph } from "falkordb"; | ||||||||||||||||||||||||||||||||||
import { getEnvVariables } from "@/app/api/utils"; | ||||||||||||||||||||||||||||||||||
import { NextRequest, NextResponse } from "next/server"; | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
export async function GET(request: NextRequest, { params }: { params: { graph: string, node: string } }) { | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
const nodeId = parseInt(params.node); | ||||||||||||||||||||||||||||||||||
const graphId = params.graph; | ||||||||||||||||||||||||||||||||||
export async function POST(request: NextRequest, { params }: { params: Promise<{ graph: string, node: string }> }) { | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
const db = await FalkorDB.connect({url: process.env.FALKORDB_URL || 'falkor://localhost:6379',}); | ||||||||||||||||||||||||||||||||||
const graph = db.selectGraph(graphId); | ||||||||||||||||||||||||||||||||||
const p = await params; | ||||||||||||||||||||||||||||||||||
Comment on lines
+4
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add input validation for 'repo' and 'src' parameters The 'repo' and 'src' parameters are used without validation. Ensure they are valid to prevent potential errors. Apply this diff: const p = await params;
const repo = p.graph;
const src = Number(p.node);
+ if (!repo || typeof repo !== 'string' || !repo.trim()) {
+ throw new Error("Repository name is required and must be a non-empty string");
+ }
+ if (isNaN(src)) {
+ throw new Error("Source node ID is required and must be a valid number");
+ } 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
// Get node's neighbors | ||||||||||||||||||||||||||||||||||
const q_params = {nodeId: nodeId}; | ||||||||||||||||||||||||||||||||||
const query = `MATCH (src)-[e]-(n) | ||||||||||||||||||||||||||||||||||
WHERE ID(src) = $nodeId | ||||||||||||||||||||||||||||||||||
RETURN collect(distinct { label:labels(n)[0], id:ID(n), name: n.name } ) as nodes, | ||||||||||||||||||||||||||||||||||
collect( { src: ID(startNode(e)), id: ID(e), dest: ID(endNode(e)), type: type(e) } ) as edges`; | ||||||||||||||||||||||||||||||||||
const repo = p.graph; | ||||||||||||||||||||||||||||||||||
const src = Number(p.node); | ||||||||||||||||||||||||||||||||||
const dest = Number(request.nextUrl.searchParams.get('targetId')) | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
let res: any = await graph.query(query, { params: q_params }); | ||||||||||||||||||||||||||||||||||
let nodes = res.data[0]['nodes']; | ||||||||||||||||||||||||||||||||||
let edges = res.data[0]['edges']; | ||||||||||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
return NextResponse.json({ id: graphId, nodes: nodes, edges: edges }, { status: 200 }) | ||||||||||||||||||||||||||||||||||
if (!dest) { | ||||||||||||||||||||||||||||||||||
throw new Error("targetId is required"); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
const { url, token } = getEnvVariables() | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
const result = await fetch(`${url}/find_paths`, { | ||||||||||||||||||||||||||||||||||
method: 'POST', | ||||||||||||||||||||||||||||||||||
headers: { | ||||||||||||||||||||||||||||||||||
"Authorization": token, | ||||||||||||||||||||||||||||||||||
'Content-Type': 'application/json' | ||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||
body: JSON.stringify({ | ||||||||||||||||||||||||||||||||||
repo, | ||||||||||||||||||||||||||||||||||
src, | ||||||||||||||||||||||||||||||||||
dest | ||||||||||||||||||||||||||||||||||
}), | ||||||||||||||||||||||||||||||||||
cache: 'no-store' | ||||||||||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
if (!result.ok) { | ||||||||||||||||||||||||||||||||||
throw new Error(await result.text()) | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
const json = await result.json() | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
return NextResponse.json({ result: json }, { status: 200 }) | ||||||||||||||||||||||||||||||||||
} catch (err) { | ||||||||||||||||||||||||||||||||||
console.error(err) | ||||||||||||||||||||||||||||||||||
return NextResponse.json((err as Error).message, { status: 400 }) | ||||||||||||||||||||||||||||||||||
Comment on lines
+42
to
+43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid exposing internal error messages to the client Returning internal error messages can leak sensitive information. Return a generic error message and log the detailed error internally. Apply this diff: console.error(err)
- return NextResponse.json((err as Error).message, { status: 400 })
+ return NextResponse.json({ message: 'An error occurred while processing your request' }, { status: 500 }) 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,37 @@ | ||||||||||||||||||||||
import { getEnvVariables } from "@/app/api/utils"; | ||||||||||||||||||||||
import { NextRequest, NextResponse } from "next/server"; | ||||||||||||||||||||||
|
||||||||||||||||||||||
export async function GET(request: NextRequest, { params }: { params: Promise<{ graph: string }> }) { | ||||||||||||||||||||||
|
||||||||||||||||||||||
const repo = (await params).graph | ||||||||||||||||||||||
|
||||||||||||||||||||||
Comment on lines
+4
to
+7
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add input validation for the 'repo' parameter The 'repo' parameter is used without validation. Ensure that 'repo' is not null or improperly formatted to prevent potential errors or security issues. Apply this diff: const repo = (await params).graph
+ if (!repo || typeof repo !== 'string' || !repo.trim()) {
+ throw new Error("Repository name is required and must be a non-empty string")
+ } 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||
try { | ||||||||||||||||||||||
|
||||||||||||||||||||||
const { url, token } = getEnvVariables() | ||||||||||||||||||||||
|
||||||||||||||||||||||
const result = await fetch(`${url}/list_commits`, { | ||||||||||||||||||||||
method: 'POST', | ||||||||||||||||||||||
body: JSON.stringify({ repo }), | ||||||||||||||||||||||
headers: { | ||||||||||||||||||||||
"Authorization": token, | ||||||||||||||||||||||
"Content-Type": 'application/json' | ||||||||||||||||||||||
}, | ||||||||||||||||||||||
cache: 'no-store' | ||||||||||||||||||||||
}) | ||||||||||||||||||||||
|
||||||||||||||||||||||
if (!result.ok) { | ||||||||||||||||||||||
throw new Error(await result.text()) | ||||||||||||||||||||||
} | ||||||||||||||||||||||
|
||||||||||||||||||||||
const json = await result.json() | ||||||||||||||||||||||
|
||||||||||||||||||||||
return NextResponse.json({ result: json }, { status: 200 }) | ||||||||||||||||||||||
} catch (err) { | ||||||||||||||||||||||
console.error(err) | ||||||||||||||||||||||
return NextResponse.json((err as Error).message, { status: 400 }) | ||||||||||||||||||||||
} | ||||||||||||||||||||||
} | ||||||||||||||||||||||
|
||||||||||||||||||||||
export async function POST(request: NextRequest, { params }: { params: Promise<{ graph: string }> }) { | ||||||||||||||||||||||
|
||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { NextRequest, NextResponse } from "next/server"; | ||
import { getEnvVariables } from "@/app/api/utils"; | ||
|
||
export async function GET(request: NextRequest, { params }: { params: Promise<{ graph: string }> }) { | ||
|
||
const repo = (await params).graph | ||
|
||
try { | ||
|
||
const { url, token } = getEnvVariables(); | ||
|
||
const result = await fetch(`${url}/repo_info`, { | ||
method: 'POST', | ||
body: JSON.stringify({ repo }), | ||
headers: { | ||
"Authorization": token, | ||
"Content-Type": 'application/json' | ||
}, | ||
cache: 'no-store' | ||
}) | ||
|
||
if (!result.ok) { | ||
throw new Error(await result.text()) | ||
} | ||
|
||
const json = await result.json() | ||
|
||
return NextResponse.json({ result: json }, { status: 200 }) | ||
} catch (err) { | ||
console.error(err) | ||
return NextResponse.json((err as Error).message, { status: 400 }) | ||
} | ||
} | ||
Comment on lines
+4
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Based on the comprehensive search results, I can now provide a final response: Rate limiting implementation needed The codebase currently lacks any rate limiting mechanisms for the API endpoints. This could potentially expose the service to abuse. Specific concerns:
🔗 Analysis chainVerify rate limiting implementation The endpoint might need rate limiting to prevent abuse. Let me check for rate limiting implementations using different search patterns and also look for any middleware configurations. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Check if rate limiting is implemented elsewhere in the codebase
echo "Searching for rate limiting implementations..."
# Look for common rate limiting patterns
rg -i "rate.?limit|throttle" --type ts
# Check for common rate limiting middleware
rg -i "middleware.*rate" --type ts
# Look for rate limiting packages in package.json
if [ -f "package.json" ]; then
echo "Checking package.json for rate limiting packages..."
cat package.json | grep -i "rate-limit"
fi
Length of output: 359 Script: #!/bin/bash
# Search for middleware configurations
echo "Checking middleware configurations..."
fd middleware -e ts -e js --exec cat {}
# Look for API route configurations
echo "Checking API route configurations..."
fd route.ts$ --exec cat {}
# Check for any config files that might contain rate limiting
echo "Checking config files..."
fd config -e ts -e js --exec cat {}
# Check package.json content for any security or middleware packages
echo "Checking package.json dependencies..."
cat package.json
Length of output: 15722 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { NextRequest, NextResponse } from "next/server"; | ||
import { getEnvVariables } from "@/app/api/utils"; | ||
|
||
export async function POST(request: NextRequest, { params }: { params: Promise<{ graph: string }> }) { | ||
|
||
const repo = (await params).graph; | ||
const node_ids = (await request.json()).nodeIds.map((id: string) => Number(id)); | ||
|
||
try { | ||
|
||
const { url, token } = getEnvVariables(); | ||
|
||
if (node_ids.length === 0) { | ||
throw new Error("nodeIds is required"); | ||
} | ||
|
||
const result = await fetch(`${url}/get_neighbors`, { | ||
method: 'POST', | ||
body: JSON.stringify({ node_ids, repo }), | ||
headers: { | ||
"Content-Type": 'application/json', | ||
"Authorization": token, | ||
}, | ||
cache: 'no-store' | ||
}) | ||
|
||
const json = await result.json() | ||
|
||
return NextResponse.json({ result: json }, { status: 200 }) | ||
} catch (err) { | ||
console.error(err) | ||
return NextResponse.json((err as Error).message, { status: 400 }) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve service container reliability
latest
tag can lead to non-deterministic builds. Pin to a specific version.📝 Committable suggestion