Skip to content

Commit

Permalink
Update postman flags to be less confusing (#2755)
Browse files Browse the repository at this point in the history
* Update postman flags to be less confusing

* Update readme

* fmt
  • Loading branch information
dustin-decker authored May 10, 2024
1 parent 0712df0 commit 9d4eb95
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 17 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

---

# :mag_right: _Now Scanning_
# :mag*right: \_Now Scanning*

<div align="center">

Expand Down Expand Up @@ -64,7 +64,7 @@ brew install trufflehog

### Docker:

<sub><i>*Ensure Docker engine is running before executing the following commands:*</i></sub>
<sub><i>_Ensure Docker engine is running before executing the following commands:_</i></sub>

#### &nbsp;&nbsp;&nbsp;&nbsp;Unix

Expand Down Expand Up @@ -261,10 +261,10 @@ trufflehog git file://. --since-commit main --branch feature-1 --only-verified -
## 12: Scan a Postman workspace
Use the `--workspace`, `--collection`, `--environment` flags multiple times to scan multiple targets.
Use the `--workspace-id`, `--collection-id`, `--environment` flags multiple times to scan multiple targets.
```bash
trufflehog postman --token=<postman api token> --workspace=<workspace id>
trufflehog postman --token=<postman api token> --workspace-id=<workspace id>
```
# :question: FAQ
Expand Down Expand Up @@ -497,7 +497,7 @@ If you'd like to specify specific `base` and `head` refs, you can use the `base`
```yaml
stages:
- security
security-secrets:
stage: security
allow_failure: false
Expand Down Expand Up @@ -626,7 +626,7 @@ class Verifier(BaseHTTPRequestHandler):
self.log_message("%s", request)
# check the match, you'll need to implement validateToken, which takes an array of ID's and Secrets
if not validateTokens(request['HogTokenDetector']['hogID'], request['HogTokenDetector']['hogSecret']):
if not validateTokens(request['HogTokenDetector']['hogID'], request['HogTokenDetector']['hogSecret']):
self.send_response(200)
self.end_headers()
else:
Expand Down
53 changes: 42 additions & 11 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,25 @@ var (
travisCiScanToken = travisCiScan.Flag("token", "TravisCI token. Can also be provided with environment variable").Envar("TRAVISCI_TOKEN").Required().String()

// Postman is hidden for now until we get more feedback from the community.
postmanScan = cli.Command("postman", "Scan Postman")
postmanToken = postmanScan.Flag("token", "Postman token. Can also be provided with environment variable").Envar("POSTMAN_TOKEN").String()
postmanWorkspaces = postmanScan.Flag("workspace", "Postman workspace to scan. You can repeat this flag.").Strings()
postmanCollections = postmanScan.Flag("collection", "Postman collection to scan. You can repeat this flag.").Strings()
postmanEnvironments = postmanScan.Flag("environment", "Postman environment to scan. You can repeat this flag.").Strings()
postmanIncludeCollections = postmanScan.Flag("include-collections", "Collections to include in scan. You can repeat this flag.").Strings()
postmanScan = cli.Command("postman", "Scan Postman")
postmanToken = postmanScan.Flag("token", "Postman token. Can also be provided with environment variable").Envar("POSTMAN_TOKEN").String()

postmanWorkspaces = postmanScan.Flag("workspace", "Postman workspace to scan. You can repeat this flag. Deprecated flag.").Hidden().Strings()
postmanWorkspaceIDs = postmanScan.Flag("workspace-id", "Postman workspace ID to scan. You can repeat this flag.").Strings()

postmanCollections = postmanScan.Flag("collection", "Postman collection to scan. You can repeat this flag. Deprecated flag.").Hidden().Strings()
postmanCollectionIDs = postmanScan.Flag("collection-id", "Postman collection ID to scan. You can repeat this flag.").Strings()

postmanEnvironments = postmanScan.Flag("environment", "Postman environment to scan. You can repeat this flag.").Strings()

postmanIncludeCollections = postmanScan.Flag("include-collections", "Collections to include in scan. You can repeat this flag. Deprecated flag.").Hidden().Strings()
postmanIncludeCollectionIDs = postmanScan.Flag("include-collection-id", "Collection ID to include in scan. You can repeat this flag.").Strings()

postmanIncludeEnvironments = postmanScan.Flag("include-environments", "Environments to include in scan. You can repeat this flag.").Strings()
postmanExcludeCollections = postmanScan.Flag("exclude-collections", "Collections to exclude from scan. You can repeat this flag.").Strings()

postmanExcludeCollections = postmanScan.Flag("exclude-collections", "Collections to exclude from scan. You can repeat this flag. Deprecated flag.").Hidden().Strings()
postmanExcludeCollectionIDs = postmanScan.Flag("exclude-collection-id", "Collection ID to exclude from scan. You can repeat this flag.").Strings()

postmanExcludeEnvironments = postmanScan.Flag("exclude-environments", "Environments to exclude from scan. You can repeat this flag.").Strings()
postmanWorkspacePaths = postmanScan.Flag("workspace-paths", "Path to Postman workspaces.").Strings()
postmanCollectionPaths = postmanScan.Flag("collection-paths", "Path to Postman collections.").Strings()
Expand Down Expand Up @@ -592,14 +603,34 @@ func run(state overseer.State) {
logFatal(err, "Failed to scan Docker.")
}
case postmanScan.FullCommand():
// handle deprecated flag
workspaceIDs := make([]string, 0, len(*postmanWorkspaceIDs)+len(*postmanWorkspaces))
workspaceIDs = append(workspaceIDs, *postmanWorkspaceIDs...)
workspaceIDs = append(workspaceIDs, *postmanWorkspaces...)

// handle deprecated flag
collectionIDs := make([]string, 0, len(*postmanCollectionIDs)+len(*postmanCollections))
collectionIDs = append(collectionIDs, *postmanCollectionIDs...)
collectionIDs = append(collectionIDs, *postmanCollections...)

// handle deprecated flag
includeCollectionIDs := make([]string, 0, len(*postmanIncludeCollectionIDs)+len(*postmanIncludeCollections))
includeCollectionIDs = append(includeCollectionIDs, *postmanIncludeCollectionIDs...)
includeCollectionIDs = append(includeCollectionIDs, *postmanIncludeCollections...)

// handle deprecated flag
excludeCollectionIDs := make([]string, 0, len(*postmanExcludeCollectionIDs)+len(*postmanExcludeCollections))
excludeCollectionIDs = append(excludeCollectionIDs, *postmanExcludeCollectionIDs...)
excludeCollectionIDs = append(excludeCollectionIDs, *postmanExcludeCollections...)

cfg := sources.PostmanConfig{
Token: *postmanToken,
Workspaces: *postmanWorkspaces,
Collections: *postmanCollections,
Workspaces: workspaceIDs,
Collections: collectionIDs,
Environments: *postmanEnvironments,
IncludeCollections: *postmanIncludeCollections,
IncludeCollections: includeCollectionIDs,
IncludeEnvironments: *postmanIncludeEnvironments,
ExcludeCollections: *postmanExcludeCollections,
ExcludeCollections: excludeCollectionIDs,
ExcludeEnvironments: *postmanExcludeEnvironments,
CollectionPaths: *postmanCollectionPaths,
WorkspacePaths: *postmanWorkspacePaths,
Expand Down

0 comments on commit 9d4eb95

Please sign in to comment.