Skip to content

Commit

Permalink
Add scan
Browse files Browse the repository at this point in the history
  • Loading branch information
hahwul committed Jan 11, 2022
1 parent d171d09 commit b363ac9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
20 changes: 16 additions & 4 deletions cmd/scan.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
package cmd

import (
"fmt"

"github.com/hahwul/authz0/pkg/scan"
"github.com/spf13/cobra"
)

var cookie, scanRolename string
var headers []string

// scanCmd represents the scan command
var scanCmd = &cobra.Command{
Use: "scan",
Use: "scan <filename>",
Short: "Scanning",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("scan called")
scanArguments := scan.ScanArguments{
RoleName: scanRolename,
Cookie: cookie,
Headers: headers,
}
if len(args) >= 1 {
scan.Run(args[0], scanArguments)
}
},
}

func init() {
rootCmd.AddCommand(scanCmd)
scanCmd.PersistentFlags().StringVarP(&cookie, "cookie", "c", "", "Cookie value of this test case")
scanCmd.PersistentFlags().StringVarP(&scanRolename, "rolename", "r", "", "Role name of this test case")
scanCmd.PersistentFlags().StringSliceVarP(&headers, "header", "H", []string{}, "Headers of this test case")
}
13 changes: 13 additions & 0 deletions pkg/scan/scan.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package scan

type ScanArguments struct {
RoleName string
Cookie string
Headers []string
}

func Run(filename string, arguments ScanArguments), {
template := authz0.FileToTemplate(filename)
_ = template
// TODO: Add scanning logic
}

0 comments on commit b363ac9

Please sign in to comment.