@@ -46,14 +46,14 @@ func NewHTTPController(dependencyVulnRepository core.DependencyVulnRepository, d
4646 }
4747}
4848
49- func (c dependencyVulnHTTPController ) ListByOrgPaged (ctx core.Context ) error {
49+ func (controller dependencyVulnHTTPController ) ListByOrgPaged (ctx core.Context ) error {
5050
51- userAllowedProjectIds , err := c .projectService .ListAllowedProjects (ctx )
51+ userAllowedProjectIds , err := controller .projectService .ListAllowedProjects (ctx )
5252 if err != nil {
5353 return echo .NewHTTPError (500 , "could not get projects" ).WithInternal (err )
5454 }
5555
56- pagedResp , err := c .dependencyVulnRepository .GetDefaultDependencyVulnsByOrgIDPaged (
56+ pagedResp , err := controller .dependencyVulnRepository .GetDefaultDependencyVulnsByOrgIDPaged (
5757 nil ,
5858
5959 utils .Map (userAllowedProjectIds , func (p models.Project ) string {
@@ -73,10 +73,10 @@ func (c dependencyVulnHTTPController) ListByOrgPaged(ctx core.Context) error {
7373 }))
7474}
7575
76- func (c dependencyVulnHTTPController ) ListByProjectPaged (ctx core.Context ) error {
76+ func (controller dependencyVulnHTTPController ) ListByProjectPaged (ctx core.Context ) error {
7777 project := core .GetProject (ctx )
7878
79- pagedResp , err := c .dependencyVulnRepository .GetDefaultDependencyVulnsByProjectIDPaged (
79+ pagedResp , err := controller .dependencyVulnRepository .GetDefaultDependencyVulnsByProjectIDPaged (
8080 nil ,
8181 project .ID ,
8282
@@ -95,13 +95,13 @@ func (c dependencyVulnHTTPController) ListByProjectPaged(ctx core.Context) error
9595 }))
9696}
9797
98- func (c dependencyVulnHTTPController ) ListPaged (ctx core.Context ) error {
98+ func (controller dependencyVulnHTTPController ) ListPaged (ctx core.Context ) error {
9999 // get the asset
100100 assetVersion := core .GetAssetVersion (ctx )
101101
102102 // check if we should list flat - this means not grouped by package
103103 if ctx .QueryParam ("flat" ) == "true" {
104- dependencyVulns , err := c .dependencyVulnRepository .GetDependencyVulnsByAssetVersionPagedAndFlat (nil , assetVersion .Name , assetVersion .AssetID , core .GetPageInfo (ctx ), ctx .QueryParam ("search" ), core .GetFilterQuery (ctx ), core .GetSortQuery (ctx ))
104+ dependencyVulns , err := controller .dependencyVulnRepository .GetDependencyVulnsByAssetVersionPagedAndFlat (nil , assetVersion .Name , assetVersion .AssetID , core .GetPageInfo (ctx ), ctx .QueryParam ("search" ), core .GetFilterQuery (ctx ), core .GetSortQuery (ctx ))
105105 if err != nil {
106106 return echo .NewHTTPError (500 , "could not get dependencyVulns" ).WithInternal (err )
107107 }
@@ -111,7 +111,7 @@ func (c dependencyVulnHTTPController) ListPaged(ctx core.Context) error {
111111 }))
112112 }
113113
114- pagedResp , packageNameIndexMap , err := c .dependencyVulnRepository .GetByAssetVersionPaged (
114+ pagedResp , packageNameIndexMap , err := controller .dependencyVulnRepository .GetByAssetVersionPaged (
115115 nil ,
116116 assetVersion .Name ,
117117 assetVersion .AssetID ,
@@ -191,7 +191,7 @@ func (c dependencyVulnHTTPController) ListPaged(ctx core.Context) error {
191191 return ctx .JSON (200 , core .NewPaged (core .GetPageInfo (ctx ), pagedResp .Total , values ))
192192}
193193
194- func (c dependencyVulnHTTPController ) Mitigate (ctx core.Context ) error {
194+ func (controller dependencyVulnHTTPController ) Mitigate (ctx core.Context ) error {
195195 type justification struct {
196196 Comment string `json:"comment"`
197197 }
@@ -218,23 +218,23 @@ func (c dependencyVulnHTTPController) Mitigate(ctx core.Context) error {
218218 }
219219
220220 // fetch the dependencyVuln again from the database. We do not know anything what might have changed. The third party integrations might have changed the state of the dependency_vuln.
221- dependencyVuln , err := c .dependencyVulnRepository .Read (dependencyVulnID )
221+ dependencyVuln , err := controller .dependencyVulnRepository .Read (dependencyVulnID )
222222 if err != nil {
223223 return echo .NewHTTPError (404 , "could not find dependencyVuln" )
224224 }
225225
226226 return ctx .JSON (200 , convertToDetailedDTO (dependencyVuln ))
227227}
228228
229- func (c dependencyVulnHTTPController ) Read (ctx core.Context ) error {
229+ func (controller dependencyVulnHTTPController ) Read (ctx core.Context ) error {
230230
231231 dependencyVulnID , _ , err := core .GetVulnID (ctx )
232232 if err != nil {
233233 return echo .NewHTTPError (400 , "invalid dependencyVuln id" )
234234 }
235235 asset := core .GetAsset (ctx )
236236
237- dependencyVuln , err := c .dependencyVulnRepository .Read (dependencyVulnID )
237+ dependencyVuln , err := controller .dependencyVulnRepository .Read (dependencyVulnID )
238238 if err != nil {
239239 return echo .NewHTTPError (404 , "could not find dependencyVuln" )
240240 }
@@ -246,7 +246,28 @@ func (c dependencyVulnHTTPController) Read(ctx core.Context) error {
246246 return ctx .JSON (200 , convertToDetailedDTO (dependencyVuln ))
247247}
248248
249- func (c dependencyVulnHTTPController ) CreateEvent (ctx core.Context ) error {
249+ func (controller dependencyVulnHTTPController ) Hints (ctx core.Context ) error {
250+ //if enabled in org settings we also want to send hints
251+ org := core .GetOrg (ctx )
252+
253+ dependencyVulnID , _ , err := core .GetVulnID (ctx )
254+ if err != nil {
255+ return echo .NewHTTPError (400 , "invalid dependencyVuln id" )
256+ }
257+
258+ dependencyVuln , err := controller .dependencyVulnRepository .Read (dependencyVulnID )
259+ if err != nil {
260+ return echo .NewHTTPError (404 , "could not find dependencyVuln" )
261+ }
262+
263+ hints , err := controller .dependencyVulnRepository .GetHintsInOrganizationForVuln (nil , org .ID , * dependencyVuln .ComponentPurl , * dependencyVuln .CVEID )
264+ if err != nil {
265+ return err
266+ }
267+ return ctx .JSON (200 , hints )
268+ }
269+
270+ func (controller dependencyVulnHTTPController ) CreateEvent (ctx core.Context ) error {
250271 asset := core .GetAsset (ctx )
251272 assetVersion := core .GetAssetVersion (ctx )
252273 thirdPartyIntegration := core .GetThirdPartyIntegration (ctx )
@@ -255,7 +276,7 @@ func (c dependencyVulnHTTPController) CreateEvent(ctx core.Context) error {
255276 return echo .NewHTTPError (400 , "invalid dependencyVuln id" )
256277 }
257278
258- dependencyVuln , err := c .dependencyVulnRepository .Read (dependencyVulnID )
279+ dependencyVuln , err := controller .dependencyVulnRepository .Read (dependencyVulnID )
259280 if err != nil {
260281 return echo .NewHTTPError (404 , "could not find dependencyVuln" )
261282 }
@@ -275,7 +296,7 @@ func (c dependencyVulnHTTPController) CreateEvent(ctx core.Context) error {
275296 justification := status .Justification
276297 mechanicalJustification := status .MechanicalJustification
277298
278- ev , err := c .dependencyVulnService .UpdateDependencyVulnState (nil , asset .ID , userID , & dependencyVuln , statusType , justification , mechanicalJustification , assetVersion .Name )
299+ ev , err := controller .dependencyVulnService .UpdateDependencyVulnState (nil , asset .ID , userID , & dependencyVuln , statusType , justification , mechanicalJustification , assetVersion .Name )
279300 if err != nil {
280301 return err
281302 }
0 commit comments