Misc endpoint additions

This commit is contained in:
Ice3man
2022-12-05 23:02:18 +05:30
parent ae36dec68c
commit 5a1a427afc
5 changed files with 24 additions and 0 deletions

View File

@@ -297,6 +297,7 @@ on extensive configurability, massive extensibility and ease of use.`)
flagSet.BoolVarP(&options.ListDatasources, "list-datasources", "ld", false, "list cloud datasources"),
flagSet.BoolVarP(&options.ListTargets, "list-targets", "clt", false, "list cloud targets"),
flagSet.BoolVarP(&options.ListTemplates, "list-templates", "ctl", false, "list cloud templates"),
flagSet.StringVarP(&options.RemoveDatasource, "remove-datasource", "rds", "", "remove specified data source"),
)
_ = flagSet.Parse()

View File

@@ -94,6 +94,10 @@ func (r *Runner) listTemplates() error {
return err
}
func (r *Runner) removeDatasource(datasource string) error {
return r.cloudClient.RemoveDatasource(datasource)
}
// initializeCloudDataSources initializes cloud data sources
func (r *Runner) initializeCloudDataSources() ([]string, error) {
var ids []string

View File

@@ -298,6 +298,21 @@ func (c *Client) ListTemplates() ([]GetTemplatesResponse, error) {
return items, nil
}
func (c *Client) RemoveDatasource(datasource string) error {
httpReq, err := retryablehttp.NewRequest(http.MethodDelete, fmt.Sprintf("%s/datasources/%s", c.baseURL, datasource), nil)
if err != nil {
return errors.Wrap(err, "could not make request")
}
resp, err := c.sendRequest(httpReq)
if err != nil {
return errors.Wrap(err, "could not do request")
}
defer resp.Body.Close()
_, _ = io.Copy(io.Discard, resp.Body)
return nil
}
const apiKeyParameter = "X-API-Key"
type errorResponse struct {

View File

@@ -476,6 +476,8 @@ func (r *Runner) RunEnumeration() error {
err = r.listTargets()
} else if r.options.ListTemplates {
err = r.listTemplates()
} else if r.options.RemoveDatasource != "" {
err = r.removeDatasource(r.options.RemoveDatasource)
} else {
gologger.Info().Msgf("Running scan on cloud with URL %s", r.options.CloudURL)
results, err = r.runCloudEnumeration(store, cloudTemplates, cloudTargets, r.options.NoStore, r.options.OutputLimit)

View File

@@ -109,6 +109,8 @@ type Options struct {
NoStore bool
// Delete scan
DeleteScan string
// RemoveDatasource deletes a datasource from cloud storage
RemoveDatasource string
// Get issues for a scan
ScanOutput string
// ResolversFile is a file containing resolvers for nuclei.