Skip to content

Commit 4c46611

Browse files
committed
Added custom date, email, and URL flags
1 parent 1195ff7 commit 4c46611

File tree

4 files changed

+206
-178
lines changed

4 files changed

+206
-178
lines changed

cmd/automate.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"io"
66
"os"
77
"strings"
8+
"time"
89

910
"github.com/spf13/cobra"
1011

@@ -44,6 +45,12 @@ responds in an abnormal way, manual testing should be conducted (prepare manual
4445
}
4546
}
4647

48+
_, err := time.Parse("2006-01-02", customDate)
49+
if err != nil {
50+
fmt.Println("An invalid date was supplied. Please supply a date in '2006-01-02' format.")
51+
os.Exit(1)
52+
}
53+
4754
var bodyBytes []byte
4855

4956
client := CheckAndConfigureProxy()

cmd/prepare.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"io"
66
"os"
7+
"time"
78

89
log "github.com/sirupsen/logrus"
910
"github.com/spf13/cobra"
@@ -22,6 +23,12 @@ This enables you to test specific API functions for common vulnerabilities or mi
2223
}
2324
}
2425

26+
_, err := time.Parse("2006-01-02", customDate)
27+
if err != nil {
28+
fmt.Println("An invalid date was supplied. Please supply a date in '2006-01-02' format.")
29+
os.Exit(1)
30+
}
31+
2532
client := CheckAndConfigureProxy()
2633

2734
fmt.Printf("\n")

cmd/root.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import (
77

88
var apiTarget string
99
var basePath string
10+
var customDate string
11+
var customEmail string
12+
var customURL string
1013
var format string
1114
var insecure bool
1215
var localFile string
@@ -49,7 +52,7 @@ $ sj convert -u https://petstore.swagger.io/v2/swagger.json -o openapi.json`,
4952
log.Error("Command not specified. See the --help flag for usage.")
5053
}
5154
},
52-
Version: "2.2.1",
55+
Version: "2.3.0",
5356
}
5457

5558
func Execute() {
@@ -64,6 +67,9 @@ func init() {
6467
rootCmd.AddCommand(convertCmd)
6568
rootCmd.PersistentFlags().StringVarP(&UserAgent, "agent", "A", "Swagger Jacker (github.com/BishopFox/sj)", "Set the User-Agent string.")
6669
rootCmd.PersistentFlags().StringVarP(&basePath, "base-path", "b", "", "Set the API base path if not defined in the definition file (i.e. /V2/).")
70+
rootCmd.PersistentFlags().StringVarP(&customURL, "custom-url", "c", "https://bishopfox.com", "Set a custom URL to test discovered URL parameters.")
71+
rootCmd.PersistentFlags().StringVarP(&customDate, "custom-date", "d", "1990-01-01", "A custom date to test discovered date parameters.")
72+
rootCmd.PersistentFlags().StringVar(&customEmail, "custom-email", "noreply@localhost.localdomain", "A custom email address to test discovered email parameters.")
6773
rootCmd.PersistentFlags().StringVarP(&format, "format", "f", "json", "Declare the format of the definition file (json/yaml/yml/js).")
6874
rootCmd.PersistentFlags().StringArrayVarP(&Headers, "headers", "H", nil, "Add custom headers, separated by a colon (\"Name: Value\"). Multiple flags are accepted.")
6975
rootCmd.PersistentFlags().BoolVarP(&insecure, "insecure", "i", false, "Ignores server certificate validation.")

0 commit comments

Comments
 (0)