-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into populate-audit-log-fi…
…elds
- Loading branch information
Showing
36 changed files
with
1,131 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package apiclient | ||
|
||
import ( | ||
"github.com/specterops/bloodhound/src/api" | ||
v2 "github.com/specterops/bloodhound/src/api/v2" | ||
"github.com/specterops/bloodhound/src/model" | ||
"net/http" | ||
) | ||
|
||
func (s Client) ListSavedQueries() (model.SavedQueries, error) { | ||
var queries model.SavedQueries | ||
if response, err := s.Request(http.MethodGet, "api/v2/saved-queries", nil, nil); err != nil { | ||
return queries, err | ||
} else { | ||
defer response.Body.Close() | ||
|
||
if api.IsErrorResponse(response) { | ||
return queries, ReadAPIError(response) | ||
} | ||
|
||
return queries, api.ReadAPIV2ResponsePayload(&queries, response) | ||
} | ||
} | ||
|
||
func (s Client) CreateSavedQuery() (model.SavedQuery, error) { | ||
var query model.SavedQuery | ||
payload := v2.CreateSavedQueryRequest{ | ||
Query: "Match(q:Question {life: 1, universe: 1, everything: 1}) return q", | ||
Name: "AnswerToLifeUniverseEverything", | ||
} | ||
|
||
if response, err := s.Request(http.MethodPost, "api/v2/saved-queries", nil, payload); err != nil { | ||
return query, err | ||
} else { | ||
defer response.Body.Close() | ||
|
||
if api.IsErrorResponse(response) { | ||
return query, ReadAPIError(response) | ||
} | ||
|
||
return query, api.ReadAPIV2ResponsePayload(&query, response) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.