Skip to content

Commit 216b727

Browse files
authored
Merge pull request #6 from WebFuzzing/fault-codes
Update fault codes
2 parents 54dc949 + 2036060 commit 216b727

4 files changed

Lines changed: 18 additions & 137 deletions

File tree

web-report/src/assets/info.json

Lines changed: 1 addition & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -14,127 +14,5 @@
1414
"distinct_fault_types": "Total number of distinct fault types detected in the API.",
1515
"creation_date": "Date when the report was generated.",
1616
"tool_name_version": "Name and version of the tool that generated the report.",
17-
"schema_version": "Version of the schema used for the report.",
18-
"fault_codes": [
19-
{
20-
"short_definition": "HTTP_STATUS_500",
21-
"code": 100,
22-
"description": "HTTP Status 500",
23-
"test_case_name": "causes500_internalServerError"
24-
},
25-
{
26-
"short_definition": "HTTP_INVALID_PAYLOAD_SYNTAX",
27-
"code": 101,
28-
"description": "Invalid Payload Syntax",
29-
"test_case_name": "rejectedWithInvalidPayloadSyntax"
30-
},
31-
{
32-
"short_definition": "HTTP_INVALID_LOCATION",
33-
"code": 102,
34-
"description": "Invalid Location HTTP Header",
35-
"test_case_name": "returnsInvalidLocationHeader"
36-
},
37-
{
38-
"short_definition": "HTTP_NONWORKING_DELETE",
39-
"code": 103,
40-
"description": "DELETE Method Does Not Work",
41-
"test_case_name": "deleteDoesNotWork"
42-
},
43-
{
44-
"short_definition": "HTTP_REPEATED_CREATE_PUT",
45-
"code": 104,
46-
"description": "Repeated PUT Creates Resource With 201",
47-
"test_case_name": "repeatedCreatePut"
48-
},
49-
{
50-
"short_definition": "SCHEMA_INVALID_RESPONSE",
51-
"code": 200,
52-
"description": "Received A Response From API That Is Not Valid According To Its Schema",
53-
"test_case_name": "returnsSchemaInvalidResponse"
54-
},
55-
{
56-
"short_definition": "GQL_ERROR_FIELD",
57-
"code": 301,
58-
"description": "Error Field",
59-
"test_case_name": "returnedErrors"
60-
},
61-
{
62-
"short_definition": "RPC_INTERNAL_ERROR",
63-
"code": 400,
64-
"description": "Internal Error",
65-
"test_case_name": "causesInternalError"
66-
},
67-
{
68-
"short_definition": "RPC_SERVICE_ERROR",
69-
"code": 401,
70-
"description": "Service Error",
71-
"test_case_name": "causesServiceError"
72-
},
73-
{
74-
"short_definition": "RPC_DECLARED_EXCEPTION",
75-
"code": 402,
76-
"description": "Declared Exception",
77-
"test_case_name": "throwsExpectedException"
78-
},
79-
{
80-
"short_definition": "RPC_UNEXPECTED_EXCEPTION",
81-
"code": 403,
82-
"description": "Unexpected Exception",
83-
"test_case_name": "throwsUnexpectedException"
84-
},
85-
{
86-
"short_definition": "RPC_HANDLED_ERROR",
87-
"code": 404,
88-
"description": "Business Logic Error",
89-
"test_case_name": "failsToExecuteCall"
90-
},
91-
{
92-
"short_definition": "WEB_BROKEN_LINK",
93-
"code": 500,
94-
"description": "Broken Link",
95-
"test_case_name": "returnsBrokenLink"
96-
},
97-
{
98-
"short_definition": "SECURITY_EXISTENCE_LEAKAGE",
99-
"code": 800,
100-
"description": "Leakage Information Existence of Protected Resource",
101-
"test_case_name": "allowsUnauthorizedAccessToProtectedResource"
102-
},
103-
{
104-
"short_definition": "SECURITY_NOT_RECOGNIZED_AUTHENTICATED",
105-
"code": 801,
106-
"description": "Wrongly Not Recognized as Authenticated",
107-
"test_case_name": "failedToAuthenticateWithValidCredentials"
108-
},
109-
{
110-
"short_definition": "SECURITY_FORBIDDEN_DELETE",
111-
"code": 802,
112-
"description": "Forbidden Delete But Allowed Modifications",
113-
"test_case_name": "forbidsDeleteButAllowsModifications"
114-
},
115-
{
116-
"short_definition": "SECURITY_FORBIDDEN_PUT",
117-
"code": 803,
118-
"description": "Forbidden Replacement But Allowed Modifications",
119-
"test_case_name": "forbidsReplacementButAllowsModifications"
120-
},
121-
{
122-
"short_definition": "SECURITY_FORBIDDEN_PATCH",
123-
"code": 804,
124-
"description": "Forbidden Updates But Allowed Modifications",
125-
"test_case_name": "forbidsUpdatesButAllowsModifications"
126-
},
127-
{
128-
"short_definition": "SECURITY_ALLOW_MODIFICATION_BY_ALL",
129-
"code": 805,
130-
"description": "Resource Created By An User Can Be Modified By All Other Users",
131-
"test_case_name": "createdResourceCanBeModifiedByEveryone"
132-
},
133-
{
134-
"short_definition": "SECURITY_FORGOTTEN_AUTHENTICATION",
135-
"code": 806,
136-
"description": "A Protected Resource Is Accessible Without Providing Any Authentication",
137-
"test_case_name": "forgottenAuthentication"
138-
}
139-
]
17+
"schema_version": "Version of the schema used for the report."
14018
}

web-report/src/components/FaultsComponent.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import info from "@/assets/info.json";
77
import {StatusCodeModal} from "@/components/StatusCodeModal.tsx";
88
import {ReportTooltip} from "@/components/ui/report-tooltip.tsx";
99
import {useAppContext} from "@/AppProvider.tsx";
10+
import faults from "../../../src/main/resources/wfc/faults/fault_categories.json";
1011

1112
export const FaultsComponent: React.FC<Faults> = ({total_number, found_faults}) => {
1213
const {data} = useAppContext();
@@ -22,10 +23,11 @@ export const FaultsComponent: React.FC<Faults> = ({total_number, found_faults})
2223
}
2324

2425
const getShortNameOfCode = (code: number) => {
25-
const codeInfo = info.fault_codes.find((fault) => fault.code === code);
26+
const codeInfo = faults.find((fault) => fault.code === code);
2627
if (codeInfo) {
27-
return codeInfo.short_definition;
28+
return codeInfo.descriptiveName;
2829
}
30+
return `Custom Code`;
2931
}
3032
return(
3133
<Card className="border-2 border-black p-6 rounded-none">

web-report/src/components/StatusCodeModal.tsx

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import {useEffect, useRef, useState} from "react"
2-
import info from "@/assets/info.json";
32
import {ChevronDown, ChevronUp} from "lucide-react";
3+
import faults from "../../../src/main/resources/wfc/faults/fault_categories.json";
44

55
interface FaultCode {
6-
short_definition: string
76
code: number
8-
description: string
9-
test_case_name: string
7+
descriptiveName: string
8+
fullDescription: string
9+
label: string
10+
testCaseLabel: string
1011
}
1112

1213
interface StatusCodeModalProps {
@@ -16,7 +17,6 @@ interface StatusCodeModalProps {
1617
}
1718

1819
export function StatusCodeModal({ isOpen, onClose, statusCode }: StatusCodeModalProps) {
19-
const faultCodes = info.fault_codes;
2020
const [expandedCode, setExpandedCode] = useState<number | null>(null)
2121
const selectedCodeRef = useRef<HTMLDivElement>(null)
2222
const modalContentRef = useRef<HTMLDivElement>(null)
@@ -42,7 +42,7 @@ export function StatusCodeModal({ isOpen, onClose, statusCode }: StatusCodeModal
4242

4343
// Group fault codes by their first digit (category)
4444
const groupedFaultCodes: { [key: string]: FaultCode[] } = {}
45-
faultCodes.forEach((fc) => {
45+
faults.forEach((fc) => {
4646
const category = Math.floor(fc.code / 100) * 100
4747
if (!groupedFaultCodes[category]) {
4848
groupedFaultCodes[category] = []
@@ -136,7 +136,7 @@ export function StatusCodeModal({ isOpen, onClose, statusCode }: StatusCodeModal
136136
onClick={() => toggleExpanded(fc.code)}
137137
>
138138
<div className="w-16 font-mono">{fc.code}</div>
139-
<div className="flex-1">{fc.short_definition}</div>
139+
<div className="flex-1">{fc.descriptiveName}</div>
140140
<div className="flex items-center gap-2">
141141
<div
142142
className={`w-3 h-3 rounded-full ${
@@ -156,11 +156,12 @@ export function StatusCodeModal({ isOpen, onClose, statusCode }: StatusCodeModal
156156
<div className="bg-gray-50 p-4 border-t">
157157
<div className="space-y-4">
158158
<div>
159+
<h4 className="font-semibold text-gray-800 mb-2">Label</h4>
160+
<p className="text-gray-600 mb-2">{fc.label}</p>
161+
<h4 className="font-semibold text-gray-800 mb-2">Test Case Name</h4>
162+
<p className="text-gray-600 mb-2">{fc.testCaseLabel}</p>
159163
<h4 className="font-semibold text-gray-800 mb-2">Description</h4>
160-
<p className="text-gray-700">{fc.description}</p>
161-
<p className="text-gray-600 mt-2">
162-
<span className="font-medium">Test Case Name:</span> {fc.test_case_name}
163-
</p>
164+
<p className="text-gray-600 mb-2">{fc.fullDescription}</p>
164165
</div>
165166
</div>
166167
</div>

web-report/src/lib/utils.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export const getFaultCounts = (found_faults: FoundFault[]) => {
150150
count: faultsWithCode.length,
151151
operation_count: uniqueOperationCounts,
152152
}
153-
})
153+
}).sort((a, b) => a.code - b.code);
154154
}
155155

156156
export const getFileColor = (index: number, file: string) => {

0 commit comments

Comments
 (0)