| 198 | |
| 199 | // Helper function to build TruffleHog command arguments |
| 200 | function buildTruffleHogCommand( |
| 201 | input: (typeof inputSchema)['__inferred'] & (typeof parameterSchema)['__inferred'], |
| 202 | ): string[] { |
| 203 | const args: string[] = [input.scanType]; |
| 204 | |
| 205 | // Add scan target based on scan type |
| 206 | switch (input.scanType) { |
| 207 | case 's3': |
| 208 | case 'gcs': |
| 209 | args.push(`--bucket=${input.scanTarget}`); |
| 210 | break; |
| 211 | case 'docker': |
| 212 | args.push(`--image=${input.scanTarget}`); |
| 213 | break; |
| 214 | default: |
| 215 | args.push(input.scanTarget); |
| 216 | } |
| 217 | |
| 218 | // Add results filter |
| 219 | if (input.onlyVerified) { |
| 220 | args.push('--results=verified'); |
| 221 | } else { |
| 222 | args.push('--results=verified,unknown'); |
| 223 | } |
| 224 | |
| 225 | // Add JSON output flag |
| 226 | if (input.jsonOutput) { |
| 227 | args.push('--json'); |
| 228 | } |
| 229 | |
| 230 | // Add branch flag (git/github only) |
| 231 | if (input.branch && (input.scanType === 'git' || input.scanType === 'github')) { |
| 232 | args.push(`--branch=${input.branch}`); |
| 233 | } |
| 234 | |
| 235 | // Add since-commit flag (git only) |
| 236 | if (input.sinceCommit && input.scanType === 'git') { |
| 237 | args.push(`--since-commit=${input.sinceCommit}`); |
| 238 | } |
| 239 | |
| 240 | // Add issue comments flag (github only) |
| 241 | if (input.includeIssueComments && input.scanType === 'github') { |
| 242 | args.push('--issue-comments'); |
| 243 | } |
| 244 | |
| 245 | // Add PR comments flag (github only) |
| 246 | if (input.includePRComments && input.scanType === 'github') { |
| 247 | args.push('--pr-comments'); |
| 248 | } |
| 249 | |
| 250 | // Add custom flags if provided |
| 251 | if (input.customFlags) { |
| 252 | args.push(...input.customFlags.split(' ').filter((f) => f.trim().length > 0)); |
| 253 | } |
| 254 | |
| 255 | return args; |
| 256 | } |
| 257 | |