Skip to content

Commit

Permalink
adds api endpoint for additional evidence details (#1002)
Browse files Browse the repository at this point in the history
* adds api endpoint for additional evidence details

* use shared routes
  • Loading branch information
audibleblink authored Dec 11, 2023
1 parent b4bd461 commit a5e6501
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
19 changes: 19 additions & 0 deletions backend/server/shared_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/ashirt-ops/ashirt-server/backend/contentstore"
"github.com/ashirt-ops/ashirt-server/backend/database"
"github.com/ashirt-ops/ashirt-server/backend/helpers"
"github.com/ashirt-ops/ashirt-server/backend/server/middleware"
"github.com/ashirt-ops/ashirt-server/backend/services"
"github.com/go-chi/chi/v5"
Expand Down Expand Up @@ -48,4 +49,22 @@ func bindSharedRoutes(r chi.Router, db *database.Connection, contentStore conten
}
return services.CreateTag(r.Context(), db, i)
}))

route(r, "GET", "/operations/{operation_slug}/evidence", jsonHandler(func(r *http.Request) (interface{}, error) {
dr := dissectJSONRequest(r)
timelineFilters, err := helpers.ParseTimelineQuery(dr.FromQuery("query").AsString())
if err != nil {
return nil, err
}

i := services.ListEvidenceForOperationInput{
OperationSlug: dr.FromURL("operation_slug").Required().AsString(),
Filters: timelineFilters,
}
if dr.Error != nil {
return nil, dr.Error
}
return services.ListEvidenceForOperation(r.Context(), db, contentStore, i)
}))

}
17 changes: 0 additions & 17 deletions backend/server/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,23 +463,6 @@ func bindWebRoutes(r chi.Router, db *database.Connection, contentStore contentst
return nil, services.DeleteFinding(r.Context(), db, i)
}))

route(r, "GET", "/operations/{operation_slug}/evidence", jsonHandler(func(r *http.Request) (interface{}, error) {
dr := dissectJSONRequest(r)
timelineFilters, err := helpers.ParseTimelineQuery(dr.FromQuery("query").AsString())
if err != nil {
return nil, err
}

i := services.ListEvidenceForOperationInput{
OperationSlug: dr.FromURL("operation_slug").Required().AsString(),
Filters: timelineFilters,
}
if dr.Error != nil {
return nil, dr.Error
}
return services.ListEvidenceForOperation(r.Context(), db, contentStore, i)
}))

route(r, "GET", "/operations/{operation_slug}/evidence/creators", jsonHandler(func(r *http.Request) (interface{}, error) {
dr := dissectJSONRequest(r)

Expand Down

0 comments on commit a5e6501

Please sign in to comment.