mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2026-01-31 15:53:10 +08:00
Misc endpoint additions
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user