1818
1919@ RestController
2020@ RequestMapping ("/svip/vulnerabilities" )
21+ /**
22+ * REST Controller for managing vulnerability data and alerts
23+ */
2124public class VulnerabilityController {
2225
2326 private final VulnerabilityHistoryService historyService ;
2427 private final VulnerabilityAlertRepository alertRepository ;
2528
29+ /**
30+ * Create a new VulnerabilityController
31+ *
32+ * @param historyService Service for vulnerability history
33+ * @param alertRepository Repository for vulnerability alerts
34+ */
2635 public VulnerabilityController (VulnerabilityHistoryService historyService ,
2736 VulnerabilityAlertRepository alertRepository ) {
2837 this .historyService = historyService ;
2938 this .alertRepository = alertRepository ;
3039 }
3140
3241 // Historical Tracking APIs
42+
43+ /**
44+ * Get all projects with vulnerability history
45+ *
46+ * @return List of project names
47+ */
3348 @ GetMapping ("/history/projects" )
3449 public ResponseEntity <List <String >> getAllProjects () {
3550 return ResponseEntity .ok (historyService .getAllProjects ());
3651 }
3752
53+ /**
54+ * Get vulnerability history for a project
55+ *
56+ * @param projectName Name of the project
57+ * @param days Number of days to retrieve
58+ * @return List of vulnerability history records
59+ */
3860 @ GetMapping ("/history/{projectName}" )
3961 public ResponseEntity <List <VulnerabilityHistory >> getHistory (
4062 @ PathVariable String projectName ,
4163 @ RequestParam (defaultValue = "30" ) int days ) {
4264 return ResponseEntity .ok (historyService .getTrend (projectName , days ));
4365 }
4466
67+ /**
68+ * Get the latest vulnerability history for a project
69+ *
70+ * @param projectName Name of the project
71+ * @return Latest vulnerability history record
72+ */
4573 @ GetMapping ("/history/{projectName}/latest" )
4674 public ResponseEntity <VulnerabilityHistory > getLatest (@ PathVariable String projectName ) {
4775 return ResponseEntity .ok (historyService .getLatest (projectName ));
4876 }
4977
5078 // Alert APIs
79+
80+ /**
81+ * Get all vulnerability alerts
82+ *
83+ * @return List of all vulnerability alerts
84+ */
5185 @ GetMapping ("/alerts" )
5286 public ResponseEntity <List <VulnerabilityAlert >> getAllAlerts () {
5387 return ResponseEntity .ok (alertRepository .findAllByOrderByCreatedAtDesc ());
5488 }
5589
90+ /**
91+ * Get all unacknowledged vulnerability alerts
92+ *
93+ * @return List of unacknowledged vulnerability alerts
94+ */
5695 @ GetMapping ("/alerts/unacknowledged" )
5796 public ResponseEntity <List <VulnerabilityAlert >> getUnacknowledgedAlerts () {
5897 return ResponseEntity .ok (alertRepository .findByAcknowledgedFalseOrderByCreatedAtDesc ());
5998 }
6099
100+ /**
101+ * Get statistics on vulnerability alerts
102+ *
103+ * @return Map of alert statistics
104+ */
61105 @ GetMapping ("/alerts/stats" )
62106 public ResponseEntity <Map <String , Long >> getAlertStats () {
63107 Map <String , Long > stats = new HashMap <>();
@@ -67,6 +111,13 @@ public ResponseEntity<Map<String, Long>> getAlertStats() {
67111 return ResponseEntity .ok (stats );
68112 }
69113
114+ /**
115+ * Acknowledge a vulnerability alert
116+ *
117+ * @param alertId ID of the alert to acknowledge
118+ * @param acknowledgedBy Name of the user acknowledging the alert
119+ * @return 200 OK if successful
120+ */
70121 @ PostMapping ("/alerts/{alertId}/acknowledge" )
71122 public ResponseEntity <Void > acknowledgeAlert (
72123 @ PathVariable Long alertId ,
0 commit comments