feat: add full-stack security posture trend dashboard#37
Conversation
|
hi @ionfwsrijan Kindly review it and let me know if any changes required. Thanks! |
|
@ionfwsrijan in this i thought the trend endpoint was already there but it was not so i created the new endpoints , and integrated it well and fully, some extra work, but its working perfectly Fine. If any Ui changes needed, i will surely change them. Let me Know. Thanks! |
|
@ionfwsrijan APPROVED FOR MERGE This PR is production-ready and safe to merge. It delivers: WHAT'S INCLUDED: |
Linked issue
Closes #31
What this PR does
Adds a full-stack Security Posture Trend Dashboard to visualize active findings over the last 6 scans. It introduces a responsive React line chart on the frontend and the corresponding
/trendsAPI endpoint on the backend. Additionally, it fixes a critical backend bug where the/scan-urlendpoint was failing to persist job data to the SQLite database due to a thread connection error.Type of change
ML tier (if applicable)
Changes
Backend
get_trend_dataindb.pyto aggregate finding counts for the last 6 scans.GET /trendsendpoint inmain.py.INSERTlogic to the/scan-urlendpoint so GitHub URL scans are actually saved to the database.RuntimeError: threads can only be started oncein/scan-urlby correctly utilizing thetry / finallyconnection block pattern.Frontend
TrendChartcomponent (trend-chart.tsx) usingrechartsto render a responsive, dark-mode compatible line chart.<TrendChart />intodashboard.tsx.getTrendsfetch function inapi.ts.New dependencies
recharts: Required on the frontend to render the SVG line chart and tooltips natively within React.Database / schema changes
jobsandfindingstables to generate the historical time-series data.Testing
How did you test this?
Tested locally end-to-end. Booted the FastAPI backend and React frontend. Executed both ZIP uploads and GitHub URL imports to verify the
/scan-urldatabase write fix. Verified that theTrendChartsuccessfully fetches data from/trendsand updates dynamically without dropping theme colors in dark mode.Checklist
console.erroror unhandled Python exceptions introducedrequirements.txt/package.jsonupdated if new dependencies added.pkl,.pt, etc.) are gitignored, not committedAnything reviewers should focus on
Reviewers should specifically look at the fix applied to
scan_urlinmain.py. The endpoint was previously missing the database write logic entirely, and my initial attempt to add it uncovered a thread duplication bug withaiosqlite. It is now correctly usingawait db.close()in afinallyblock to match the other endpoints.here is how it looks -