Skip to content

Commit 518c7d1

Browse files
committed
feat: layout
1 parent 8c45560 commit 518c7d1

File tree

3 files changed

+427
-4
lines changed

3 files changed

+427
-4
lines changed
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
// Dummy data for the technical review queue, used when backend is unavailable
2+
3+
export type DelphiReportSeverity = 'LOW' | 'MEDIUM' | 'HIGH' | 'SEVERE'
4+
export type DelphiReportIssueStatus = 'pending' | 'approved' | 'rejected'
5+
6+
export interface DelphiIssueJavaClass {
7+
id: number
8+
issue_id: number
9+
internal_class_name: string
10+
decompiled_source?: string | null
11+
}
12+
13+
export interface DelphiReportSummary {
14+
id: number
15+
file_id?: number | null
16+
delphi_version: number
17+
artifact_url: string
18+
created: string // ISO date
19+
severity: DelphiReportSeverity
20+
}
21+
22+
export interface DelphiIssueSummary {
23+
id: number
24+
report_id: number
25+
issue_type: string
26+
status: DelphiReportIssueStatus
27+
}
28+
29+
export interface DelphiIssueResult {
30+
issue: DelphiIssueSummary
31+
report: DelphiReportSummary
32+
java_classes: DelphiIssueJavaClass[]
33+
project_id?: number | null
34+
project_published?: string | null
35+
}
36+
37+
export const DUMMY_ISSUE_TYPES: string[] = [
38+
'reflection_indirection',
39+
'xor_obfuscation',
40+
'included_libraries',
41+
'suspicious_binaries',
42+
'corrupt_classes',
43+
'suspicious_classes',
44+
'url_usage',
45+
'classloader_usage',
46+
'processbuilder_usage',
47+
'runtime_exec_usage',
48+
'jni_usage',
49+
'main_method',
50+
'native_loading',
51+
'malformed_jar',
52+
'nested_jar_too_deep',
53+
'failed_decompilation',
54+
'analysis_failure',
55+
'malware_easyforme',
56+
'malware_simplyloader',
57+
]
58+
59+
export const DUMMY_ISSUES: DelphiIssueResult[] = [
60+
{
61+
issue: {
62+
id: 1001,
63+
report_id: 501,
64+
issue_type: 'suspicious_classes',
65+
status: 'pending',
66+
},
67+
report: {
68+
id: 501,
69+
file_id: 90001,
70+
delphi_version: 47,
71+
artifact_url: 'https://cdn.modrinth.com/data/abc/versions/1.0.0.jar',
72+
created: new Date(Date.now() - 3 * 24 * 3600 * 1000).toISOString(),
73+
severity: 'SEVERE',
74+
},
75+
java_classes: [
76+
{
77+
id: 7001,
78+
issue_id: 1001,
79+
internal_class_name: 'com/example/Suspect',
80+
decompiled_source: 'public class Suspect { /* ... */ }',
81+
},
82+
],
83+
project_id: 123456,
84+
project_published: new Date(Date.now() - 30 * 24 * 3600 * 1000).toISOString(),
85+
},
86+
{
87+
issue: {
88+
id: 1002,
89+
report_id: 502,
90+
issue_type: 'url_usage',
91+
status: 'pending',
92+
},
93+
report: {
94+
id: 502,
95+
file_id: 90002,
96+
delphi_version: 47,
97+
artifact_url: 'https://cdn.modrinth.com/data/def/versions/2.3.4.jar',
98+
created: new Date(Date.now() - 1 * 24 * 3600 * 1000).toISOString(),
99+
severity: 'HIGH',
100+
},
101+
java_classes: [],
102+
project_id: 789012,
103+
project_published: new Date(Date.now() - 45 * 24 * 3600 * 1000).toISOString(),
104+
},
105+
]
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { DUMMY_ISSUE_TYPES, DUMMY_ISSUES, type DelphiIssueResult } from './tech-review.dummy'
2+
3+
// TODO: @modrinth/api-client package
4+
5+
export type OrderBy =
6+
| 'created_asc'
7+
| 'created_desc'
8+
| 'pending_status_first'
9+
| 'severity_asc'
10+
| 'severity_desc'
11+
12+
export interface FetchIssuesParams {
13+
type?: string | null
14+
status?: 'pending' | 'approved' | 'rejected' | null
15+
order_by?: OrderBy | null
16+
count?: number
17+
offset?: number
18+
}
19+
20+
export async function fetchIssueTypeSchema(): Promise<string[]> {
21+
try {
22+
const schema = await useBaseFetch('internal/delphi/issue_type/schema', { internal: true })
23+
// Expecting a JSON object map of type -> metadata; return its keys
24+
if (schema && typeof schema === 'object') {
25+
return Object.keys(schema as Record<string, unknown>)
26+
}
27+
return DUMMY_ISSUE_TYPES
28+
} catch {
29+
return DUMMY_ISSUE_TYPES
30+
}
31+
}
32+
33+
export async function fetchDelphiIssues(params: FetchIssuesParams): Promise<DelphiIssueResult[]> {
34+
const query = new URLSearchParams()
35+
if (params.type) query.set('type', params.type)
36+
if (params.status) query.set('status', params.status)
37+
if (params.order_by) query.set('order_by', params.order_by)
38+
if (params.count != null) query.set('count', String(params.count))
39+
if (params.offset != null) query.set('offset', String(params.offset))
40+
41+
try {
42+
const res = await useBaseFetch(`internal/delphi/issues?${query.toString()}`, { internal: true })
43+
return (res as any[]) || []
44+
} catch {
45+
return DUMMY_ISSUES
46+
}
47+
}

0 commit comments

Comments
 (0)