Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -431,6 +431,66 @@ curl -X POST https://ayshajavd-code-security-analyzer.hf.space/call/analyze \\
|
|
| 431 |
| **A08: Integrity Failures** | CWE-502 |
|
| 432 |
| **A10: SSRF** | CWE-918 |
|
| 433 |
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 434 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 435 |
if __name__ == "__main__":
|
| 436 |
demo.launch()
|
|
|
|
| 431 |
| **A08: Integrity Failures** | CWE-502 |
|
| 432 |
| **A10: SSRF** | CWE-918 |
|
| 433 |
""")
|
| 434 |
+
def generate_report(
|
| 435 |
+
code,
|
| 436 |
+
prediction,
|
| 437 |
+
cwe,
|
| 438 |
+
owasp,
|
| 439 |
+
severity,
|
| 440 |
+
explanation,
|
| 441 |
+
recommendations,
|
| 442 |
+
fixed_code
|
| 443 |
+
):
|
| 444 |
+
report = f"""
|
| 445 |
+
SOFTWARE SECURITY ASSESSMENT REPORT
|
| 446 |
+
|
| 447 |
+
Analysis Result
|
| 448 |
+
---------------
|
| 449 |
+
Prediction: {prediction}
|
| 450 |
+
|
| 451 |
+
Detected Vulnerability
|
| 452 |
+
----------------------
|
| 453 |
+
CWE: {cwe}
|
| 454 |
+
OWASP: {owasp}
|
| 455 |
+
Severity: {severity}
|
| 456 |
+
|
| 457 |
+
Explanation
|
| 458 |
+
-----------
|
| 459 |
+
{explanation}
|
| 460 |
+
|
| 461 |
+
Recommendations
|
| 462 |
+
---------------
|
| 463 |
+
{recommendations}
|
| 464 |
+
|
| 465 |
+
Suggested Secure Version
|
| 466 |
+
------------------------
|
| 467 |
+
{fixed_code}
|
| 468 |
+
|
| 469 |
+
Original Code
|
| 470 |
+
-------------
|
| 471 |
+
{code}
|
| 472 |
+
"""
|
| 473 |
|
| 474 |
+
return report
|
| 475 |
+
report_output = gr.Textbox(
|
| 476 |
+
label="Security Report",
|
| 477 |
+
lines=25
|
| 478 |
+
)
|
| 479 |
+
report = generate_report(
|
| 480 |
+
code,
|
| 481 |
+
prediction,
|
| 482 |
+
cwe,
|
| 483 |
+
owasp,
|
| 484 |
+
severity,
|
| 485 |
+
explanation,
|
| 486 |
+
recommendations,
|
| 487 |
+
fixed_code
|
| 488 |
+
)
|
| 489 |
+
return (
|
| 490 |
+
prediction,
|
| 491 |
+
explanation,
|
| 492 |
+
fixed_code,
|
| 493 |
+
report
|
| 494 |
+
)
|
| 495 |
if __name__ == "__main__":
|
| 496 |
demo.launch()
|