scanProfile

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Copyright © 2024 NAME HERE <EMAIL ADDRESS>

Copyright © 2024 NAME HERE <EMAIL ADDRESS>

Copyright © 2024 NAME HERE <EMAIL ADDRESS>

Copyright © 2024 NAME HERE <EMAIL ADDRESS>

Index

Constants

This section is empty.

Variables

View Source
var AddCmd = &cobra.Command{
	Use:   "add",
	Short: "Adds the exported Scan Profile",
	Long: `Imports the exported scan profile. It takes the config json file from stdin (you can export the scan with --export flag). Example:
	cat scanProfile.json | acucli scanProfile add`,
	Run: func(cmd *cobra.Command, args []string) {
		var scanProfile ScanProfile
		data := filehelper.ReadStdin()
		var stringBuilder strings.Builder
		for _, str := range data {
			stringBuilder.WriteString(str)
		}
		combinedString := stringBuilder.String()

		byteSlice := []byte(combinedString)
		err := json.Unmarshal(byteSlice, &scanProfile)
		if err == nil {
			makeRequest(scanProfile)
		}
	},
}

addCmd represents the add command

View Source
var ListCmd = &cobra.Command{
	Use:   "list",
	Short: "List the scan profiles",
	Run: func(cmd *cobra.Command, args []string) {
		req, err := http.NewRequest("GET", fmt.Sprintf("%s%s", viper.GetString("URL"), "/scanning_profiles"), nil)
		if err != nil {
			fmt.Println("Error creating request:", err)
			return
		}

		resp, err := httpclient.MyHTTPClient.Do(req)
		if err != nil {
			fmt.Println("Error making request:", err)
			return
		}
		defer resp.Body.Close()
		body, _ := io.ReadAll(resp.Body)

		var scanProfiles ScanProfiles
		err = json.Unmarshal(body, &scanProfiles)
		if err != nil {
			fmt.Println("Error parsing JSON:", err)
			return
		}

		for _, scanProfile := range scanProfiles.ScanningProfiles {
			fmt.Printf("%s\t%s\n", scanProfile.Name, scanProfile.ProfileID)
		}
	},
}

listCmd represents the list command

View Source
var RemoveCmd = &cobra.Command{
	Use:   "remove",
	Short: "Removes the given scanProfile",
	Long: `Removes the given scanProfile. Takes the ids line by line from stdin. Example:

cat scanProfileids.txt | acucli scanProfile remove`,
	Run: func(cmd *cobra.Command, args []string) {
		input := filehelper.ReadStdin()
		if input != nil {
			makeDeleteRequest(input)
		}
	},
}

removeCmd represents the remove command

View Source
var ScanProfileCmd = &cobra.Command{
	Use:   "scanProfile",
	Short: "Manage Scan Profiles",
	Long: `Without flags with just id, it gives the summary of the Scan Profile, can also export with --export flag. Example:
	
	acucli scanProfile --id=9ef9d9ee-510e-47da-8549-43ea826d1cdc : Gives the summary of the Scan Profile
	acucli scanProfile --id=9ef9d9ee-510e-47da-8549-43ea826d1cdc --export : Exports the Scan Profile JSON
	acucli scanProfile --id=03aa8950-a289-48f3-a0f9-8416b8c5a8d5 --export --output=/home/user : Exports the Scan Profile to defined output folder

	`,
	Run: func(cmd *cobra.Command, args []string) {
		id, _ = cmd.Flags().GetString("id")
		if cmd.Flags().Changed("export") {
			output, _ := cmd.Flags().GetString("output")
			exportScanProfile(id, output)
		} else {
			responseCode, respBody := GetScanProfileRequest(id)
			if responseCode == 200 {
				fmt.Println(respBody)
			} else {
				fmt.Fprintf(os.Stderr, "%sScan Profile not found%s\n", chalk.Red, chalk.Reset)
			}
		}

	},
}

scanProfileCmd represents the scanProfile command

Functions

This section is empty.

Types

type ScanProfile

type ScanProfile struct {
	Checks    []string `json:"checks"`
	Custom    bool     `json:"custom"`
	Name      string   `json:"name"`
	ProfileID string   `json:"profile_id"`
	SortOrder int      `json:"sort_order"`
}

func GetScanProfileRequest

func GetScanProfileRequest(id string) (int, ScanProfile)

func (ScanProfile) String

func (sp ScanProfile) String() string

type ScanProfiles

type ScanProfiles struct {
	ScanningProfiles []ScanProfile `json:"scanning_profiles"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址