Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions cmd/ddb.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var (
tableNamePattern string
ddbQuery string
ddbOutputType string
ddbMatchAll *bool
ddbIncludeGlobalTables *bool
ddbListTables *bool
ddbAllowAllTables *bool
Expand Down Expand Up @@ -77,8 +78,12 @@ Search free text patterns inside Bytes, Binary, Protobuf, Base64 and Json format
Run: func(cmd *cobra.Command, args []string) {

if !*ddbListTables {
if ddbQuery == "" {
log.Fatalf("invalid output type %s only valid %v, use --help", ddbOutputType, validDDBOutputs)
if !*ddbMatchAll && ddbQuery == "" {
log.Fatalf("invalid query input empty, use --help or --all")
}

if *ddbMatchAll && ddbQuery != "" {
log.Fatalf("invalid query input %s not empty used with --all, use --help", ddbQuery)
}

if _, exist := validDDBOutputs[ddbOutputType]; !exist {
Expand All @@ -87,6 +92,7 @@ Search free text patterns inside Bytes, Binary, Protobuf, Base64 and Json format
if !*ddbAllowAllTables && tableNamePattern == "" {
log.Fatal("must use --all-tables explicitly or --table <pattern> flag, use --help")
}

}
tui := buildTUI()
// MARSHAL ATTRIBUTES UTILITY https://docs.aws.amazon.com/sdk-for-go/api/service/dynamodb/dynamodbattribute/
Expand All @@ -111,6 +117,10 @@ Search free text patterns inside Bytes, Binary, Protobuf, Base64 and Json format
return
} else {

if *ddbMatchAll {
ddbQuery = "\\..*"
}

parallel := 30
m := common.NewDefaultRegexMatcher()
p := search.NewParserFactory()
Expand Down Expand Up @@ -239,11 +249,12 @@ func init() {

ddbCmd.PersistentFlags().StringVarP(&awsProfile, "profile", "p", getDefaultProfileEnvVar(), "~/.aws/credentials chosen account")
ddbCmd.PersistentFlags().StringVarP(&awsRegion, "region", "r", "", "~/.aws/config default region if empty")
ddbCmd.PersistentFlags().StringVarP(&ddbQuery, "query", "q", "", "filter query regex supported")
ddbCmd.PersistentFlags().StringVarP(&ddbQuery, "query", "q", "", "filter query regex supported (if used with --all will error)")
ddbCmd.PersistentFlags().StringVarP(&tableNamePattern, "table", "t", "", "regex table pattern name to match")
ddbCmd.PersistentFlags().StringVarP(&ddbOutputType, "out", "o", "pretty", "output format [json, pretty]")
ddbFailFast = ddbCmd.Flags().Bool("fail-fast", false, "fail on first error seen")
ddbListTables = ddbCmd.Flags().Bool("list-tables", false, "list all available tables")
ddbMatchAll = ddbCmd.Flags().Bool("all", false, "match all data (same as using -q '\\\\..*') if used with --query will error")
ddbIncludeGlobalTables = ddbCmd.Flags().Bool("include-global-tables", true, "if true will include global tables during search")
ddbStopOnFirstMatch = ddbCmd.Flags().Bool("stop-first-match", false, "if true stop stop searching on first match found")
sanitizeOutput = ddbCmd.Flags().Bool("sanitize", true, "if true will remove all non-ascii charts from outputs")
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
)

const (
AppVersion = "2.1.1"
AppVersion = "2.1.2"
AppName = "surf"
)

Expand Down