aidevops 2.52.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agent/AGENTS.md +614 -0
- package/.agent/accounts.md +65 -0
- package/.agent/aidevops/add-new-mcp-to-aidevops.md +456 -0
- package/.agent/aidevops/api-integrations.md +335 -0
- package/.agent/aidevops/architecture.md +510 -0
- package/.agent/aidevops/configs.md +274 -0
- package/.agent/aidevops/docs.md +244 -0
- package/.agent/aidevops/extension.md +311 -0
- package/.agent/aidevops/mcp-integrations.md +340 -0
- package/.agent/aidevops/mcp-troubleshooting.md +162 -0
- package/.agent/aidevops/memory-patterns.md +172 -0
- package/.agent/aidevops/providers.md +217 -0
- package/.agent/aidevops/recommendations.md +321 -0
- package/.agent/aidevops/requirements.md +301 -0
- package/.agent/aidevops/resources.md +214 -0
- package/.agent/aidevops/security-requirements.md +174 -0
- package/.agent/aidevops/security.md +350 -0
- package/.agent/aidevops/service-links.md +400 -0
- package/.agent/aidevops/services.md +357 -0
- package/.agent/aidevops/setup.md +153 -0
- package/.agent/aidevops/troubleshooting.md +389 -0
- package/.agent/aidevops.md +124 -0
- package/.agent/build-plus.md +244 -0
- package/.agent/content/guidelines.md +109 -0
- package/.agent/content.md +87 -0
- package/.agent/health.md +59 -0
- package/.agent/legal.md +59 -0
- package/.agent/loop-state/full-loop.local.md +16 -0
- package/.agent/loop-state/ralph-loop.local.md +10 -0
- package/.agent/marketing.md +440 -0
- package/.agent/memory/README.md +260 -0
- package/.agent/onboarding.md +796 -0
- package/.agent/plan-plus.md +245 -0
- package/.agent/research.md +100 -0
- package/.agent/sales.md +333 -0
- package/.agent/scripts/101domains-helper.sh +701 -0
- package/.agent/scripts/add-missing-returns.sh +140 -0
- package/.agent/scripts/agent-browser-helper.sh +311 -0
- package/.agent/scripts/agno-setup.sh +712 -0
- package/.agent/scripts/ahrefs-mcp-wrapper.js +168 -0
- package/.agent/scripts/aidevops-update-check.sh +71 -0
- package/.agent/scripts/ampcode-cli.sh +522 -0
- package/.agent/scripts/auto-version-bump.sh +156 -0
- package/.agent/scripts/autogen-helper.sh +512 -0
- package/.agent/scripts/beads-sync-helper.sh +596 -0
- package/.agent/scripts/closte-helper.sh +5 -0
- package/.agent/scripts/cloudron-helper.sh +321 -0
- package/.agent/scripts/codacy-cli-chunked.sh +581 -0
- package/.agent/scripts/codacy-cli.sh +442 -0
- package/.agent/scripts/code-audit-helper.sh +5 -0
- package/.agent/scripts/coderabbit-cli.sh +417 -0
- package/.agent/scripts/coderabbit-pro-analysis.sh +238 -0
- package/.agent/scripts/commands/code-simplifier.md +86 -0
- package/.agent/scripts/commands/full-loop.md +246 -0
- package/.agent/scripts/commands/postflight-loop.md +103 -0
- package/.agent/scripts/commands/recall.md +182 -0
- package/.agent/scripts/commands/remember.md +132 -0
- package/.agent/scripts/commands/save-todo.md +175 -0
- package/.agent/scripts/commands/session-review.md +154 -0
- package/.agent/scripts/comprehensive-quality-fix.sh +106 -0
- package/.agent/scripts/context-builder-helper.sh +522 -0
- package/.agent/scripts/coolify-cli-helper.sh +674 -0
- package/.agent/scripts/coolify-helper.sh +380 -0
- package/.agent/scripts/crawl4ai-examples.sh +401 -0
- package/.agent/scripts/crawl4ai-helper.sh +1078 -0
- package/.agent/scripts/crewai-helper.sh +681 -0
- package/.agent/scripts/dev-browser-helper.sh +513 -0
- package/.agent/scripts/dns-helper.sh +396 -0
- package/.agent/scripts/domain-research-helper.sh +917 -0
- package/.agent/scripts/dspy-helper.sh +285 -0
- package/.agent/scripts/dspyground-helper.sh +291 -0
- package/.agent/scripts/eeat-score-helper.sh +1242 -0
- package/.agent/scripts/efficient-return-fix.sh +92 -0
- package/.agent/scripts/extract-opencode-prompts.sh +128 -0
- package/.agent/scripts/find-missing-returns.sh +113 -0
- package/.agent/scripts/fix-auth-headers.sh +104 -0
- package/.agent/scripts/fix-common-strings.sh +254 -0
- package/.agent/scripts/fix-content-type.sh +100 -0
- package/.agent/scripts/fix-error-messages.sh +130 -0
- package/.agent/scripts/fix-misplaced-returns.sh +74 -0
- package/.agent/scripts/fix-remaining-literals.sh +152 -0
- package/.agent/scripts/fix-return-statements.sh +41 -0
- package/.agent/scripts/fix-s131-default-cases.sh +249 -0
- package/.agent/scripts/fix-sc2155-simple.sh +102 -0
- package/.agent/scripts/fix-shellcheck-critical.sh +187 -0
- package/.agent/scripts/fix-string-literals.sh +273 -0
- package/.agent/scripts/full-loop-helper.sh +773 -0
- package/.agent/scripts/generate-opencode-agents.sh +497 -0
- package/.agent/scripts/generate-opencode-commands.sh +1629 -0
- package/.agent/scripts/generate-skills.sh +366 -0
- package/.agent/scripts/git-platforms-helper.sh +640 -0
- package/.agent/scripts/gitea-cli-helper.sh +743 -0
- package/.agent/scripts/github-cli-helper.sh +702 -0
- package/.agent/scripts/gitlab-cli-helper.sh +682 -0
- package/.agent/scripts/gsc-add-user-helper.sh +325 -0
- package/.agent/scripts/gsc-sitemap-helper.sh +678 -0
- package/.agent/scripts/hetzner-helper.sh +485 -0
- package/.agent/scripts/hostinger-helper.sh +229 -0
- package/.agent/scripts/keyword-research-helper.sh +1815 -0
- package/.agent/scripts/langflow-helper.sh +544 -0
- package/.agent/scripts/linkedin-automation.py +241 -0
- package/.agent/scripts/linter-manager.sh +599 -0
- package/.agent/scripts/linters-local.sh +434 -0
- package/.agent/scripts/list-keys-helper.sh +488 -0
- package/.agent/scripts/local-browser-automation.py +339 -0
- package/.agent/scripts/localhost-helper.sh +744 -0
- package/.agent/scripts/loop-common.sh +806 -0
- package/.agent/scripts/mainwp-helper.sh +728 -0
- package/.agent/scripts/markdown-formatter.sh +338 -0
- package/.agent/scripts/markdown-lint-fix.sh +311 -0
- package/.agent/scripts/mass-fix-returns.sh +58 -0
- package/.agent/scripts/mcp-diagnose.sh +167 -0
- package/.agent/scripts/mcp-inspector-helper.sh +449 -0
- package/.agent/scripts/memory-helper.sh +650 -0
- package/.agent/scripts/monitor-code-review.sh +255 -0
- package/.agent/scripts/onboarding-helper.sh +706 -0
- package/.agent/scripts/opencode-github-setup-helper.sh +797 -0
- package/.agent/scripts/opencode-test-helper.sh +213 -0
- package/.agent/scripts/pagespeed-helper.sh +464 -0
- package/.agent/scripts/pandoc-helper.sh +362 -0
- package/.agent/scripts/postflight-check.sh +555 -0
- package/.agent/scripts/pre-commit-hook.sh +259 -0
- package/.agent/scripts/pre-edit-check.sh +169 -0
- package/.agent/scripts/qlty-cli.sh +356 -0
- package/.agent/scripts/quality-cli-manager.sh +525 -0
- package/.agent/scripts/quality-feedback-helper.sh +462 -0
- package/.agent/scripts/quality-fix.sh +263 -0
- package/.agent/scripts/quality-loop-helper.sh +1108 -0
- package/.agent/scripts/ralph-loop-helper.sh +836 -0
- package/.agent/scripts/ralph-upstream-check.sh +341 -0
- package/.agent/scripts/secretlint-helper.sh +847 -0
- package/.agent/scripts/servers-helper.sh +241 -0
- package/.agent/scripts/ses-helper.sh +619 -0
- package/.agent/scripts/session-review-helper.sh +404 -0
- package/.agent/scripts/setup-linters-wizard.sh +379 -0
- package/.agent/scripts/setup-local-api-keys.sh +330 -0
- package/.agent/scripts/setup-mcp-integrations.sh +472 -0
- package/.agent/scripts/shared-constants.sh +246 -0
- package/.agent/scripts/site-crawler-helper.sh +1487 -0
- package/.agent/scripts/snyk-helper.sh +940 -0
- package/.agent/scripts/sonarcloud-autofix.sh +193 -0
- package/.agent/scripts/sonarcloud-cli.sh +191 -0
- package/.agent/scripts/sonarscanner-cli.sh +455 -0
- package/.agent/scripts/spaceship-helper.sh +747 -0
- package/.agent/scripts/stagehand-helper.sh +321 -0
- package/.agent/scripts/stagehand-python-helper.sh +321 -0
- package/.agent/scripts/stagehand-python-setup.sh +441 -0
- package/.agent/scripts/stagehand-setup.sh +439 -0
- package/.agent/scripts/system-cleanup.sh +340 -0
- package/.agent/scripts/terminal-title-helper.sh +388 -0
- package/.agent/scripts/terminal-title-setup.sh +549 -0
- package/.agent/scripts/test-stagehand-both-integration.sh +317 -0
- package/.agent/scripts/test-stagehand-integration.sh +309 -0
- package/.agent/scripts/test-stagehand-python-integration.sh +341 -0
- package/.agent/scripts/todo-ready.sh +263 -0
- package/.agent/scripts/tool-version-check.sh +362 -0
- package/.agent/scripts/toon-helper.sh +469 -0
- package/.agent/scripts/twilio-helper.sh +917 -0
- package/.agent/scripts/updown-helper.sh +279 -0
- package/.agent/scripts/validate-mcp-integrations.sh +250 -0
- package/.agent/scripts/validate-version-consistency.sh +131 -0
- package/.agent/scripts/vaultwarden-helper.sh +597 -0
- package/.agent/scripts/vercel-cli-helper.sh +816 -0
- package/.agent/scripts/verify-mirrors.sh +169 -0
- package/.agent/scripts/version-manager.sh +831 -0
- package/.agent/scripts/webhosting-helper.sh +471 -0
- package/.agent/scripts/webhosting-verify.sh +238 -0
- package/.agent/scripts/wordpress-mcp-helper.sh +508 -0
- package/.agent/scripts/worktree-helper.sh +595 -0
- package/.agent/scripts/worktree-sessions.sh +577 -0
- package/.agent/seo/dataforseo.md +215 -0
- package/.agent/seo/domain-research.md +532 -0
- package/.agent/seo/eeat-score.md +659 -0
- package/.agent/seo/google-search-console.md +366 -0
- package/.agent/seo/gsc-sitemaps.md +282 -0
- package/.agent/seo/keyword-research.md +521 -0
- package/.agent/seo/serper.md +278 -0
- package/.agent/seo/site-crawler.md +387 -0
- package/.agent/seo.md +236 -0
- package/.agent/services/accounting/quickfile.md +159 -0
- package/.agent/services/communications/telfon.md +470 -0
- package/.agent/services/communications/twilio.md +569 -0
- package/.agent/services/crm/fluentcrm.md +449 -0
- package/.agent/services/email/ses.md +399 -0
- package/.agent/services/hosting/101domains.md +378 -0
- package/.agent/services/hosting/closte.md +177 -0
- package/.agent/services/hosting/cloudflare.md +251 -0
- package/.agent/services/hosting/cloudron.md +478 -0
- package/.agent/services/hosting/dns-providers.md +335 -0
- package/.agent/services/hosting/domain-purchasing.md +344 -0
- package/.agent/services/hosting/hetzner.md +327 -0
- package/.agent/services/hosting/hostinger.md +287 -0
- package/.agent/services/hosting/localhost.md +419 -0
- package/.agent/services/hosting/spaceship.md +353 -0
- package/.agent/services/hosting/webhosting.md +330 -0
- package/.agent/social-media.md +69 -0
- package/.agent/templates/plans-template.md +114 -0
- package/.agent/templates/prd-template.md +129 -0
- package/.agent/templates/tasks-template.md +108 -0
- package/.agent/templates/todo-template.md +89 -0
- package/.agent/tools/ai-assistants/agno.md +471 -0
- package/.agent/tools/ai-assistants/capsolver.md +326 -0
- package/.agent/tools/ai-assistants/configuration.md +221 -0
- package/.agent/tools/ai-assistants/overview.md +209 -0
- package/.agent/tools/ai-assistants/status.md +171 -0
- package/.agent/tools/ai-assistants/windsurf.md +193 -0
- package/.agent/tools/ai-orchestration/autogen.md +406 -0
- package/.agent/tools/ai-orchestration/crewai.md +445 -0
- package/.agent/tools/ai-orchestration/langflow.md +405 -0
- package/.agent/tools/ai-orchestration/openprose.md +487 -0
- package/.agent/tools/ai-orchestration/overview.md +362 -0
- package/.agent/tools/ai-orchestration/packaging.md +647 -0
- package/.agent/tools/browser/agent-browser.md +464 -0
- package/.agent/tools/browser/browser-automation.md +400 -0
- package/.agent/tools/browser/chrome-devtools.md +282 -0
- package/.agent/tools/browser/crawl4ai-integration.md +422 -0
- package/.agent/tools/browser/crawl4ai-resources.md +277 -0
- package/.agent/tools/browser/crawl4ai-usage.md +416 -0
- package/.agent/tools/browser/crawl4ai.md +585 -0
- package/.agent/tools/browser/dev-browser.md +341 -0
- package/.agent/tools/browser/pagespeed.md +260 -0
- package/.agent/tools/browser/playwright.md +266 -0
- package/.agent/tools/browser/playwriter.md +310 -0
- package/.agent/tools/browser/stagehand-examples.md +456 -0
- package/.agent/tools/browser/stagehand-python.md +483 -0
- package/.agent/tools/browser/stagehand.md +421 -0
- package/.agent/tools/build-agent/agent-review.md +224 -0
- package/.agent/tools/build-agent/build-agent.md +784 -0
- package/.agent/tools/build-mcp/aidevops-plugin.md +476 -0
- package/.agent/tools/build-mcp/api-wrapper.md +445 -0
- package/.agent/tools/build-mcp/build-mcp.md +240 -0
- package/.agent/tools/build-mcp/deployment.md +401 -0
- package/.agent/tools/build-mcp/server-patterns.md +632 -0
- package/.agent/tools/build-mcp/transports.md +366 -0
- package/.agent/tools/code-review/auditing.md +383 -0
- package/.agent/tools/code-review/automation.md +219 -0
- package/.agent/tools/code-review/best-practices.md +203 -0
- package/.agent/tools/code-review/codacy.md +151 -0
- package/.agent/tools/code-review/code-simplifier.md +174 -0
- package/.agent/tools/code-review/code-standards.md +309 -0
- package/.agent/tools/code-review/coderabbit.md +101 -0
- package/.agent/tools/code-review/management.md +155 -0
- package/.agent/tools/code-review/qlty.md +248 -0
- package/.agent/tools/code-review/secretlint.md +565 -0
- package/.agent/tools/code-review/setup.md +250 -0
- package/.agent/tools/code-review/snyk.md +563 -0
- package/.agent/tools/code-review/tools.md +230 -0
- package/.agent/tools/content/summarize.md +353 -0
- package/.agent/tools/context/augment-context-engine.md +468 -0
- package/.agent/tools/context/context-builder-agent.md +76 -0
- package/.agent/tools/context/context-builder.md +375 -0
- package/.agent/tools/context/context7.md +371 -0
- package/.agent/tools/context/dspy.md +302 -0
- package/.agent/tools/context/dspyground.md +374 -0
- package/.agent/tools/context/llm-tldr.md +219 -0
- package/.agent/tools/context/osgrep.md +488 -0
- package/.agent/tools/context/prompt-optimization.md +338 -0
- package/.agent/tools/context/toon.md +292 -0
- package/.agent/tools/conversion/pandoc.md +304 -0
- package/.agent/tools/credentials/api-key-management.md +154 -0
- package/.agent/tools/credentials/api-key-setup.md +224 -0
- package/.agent/tools/credentials/environment-variables.md +180 -0
- package/.agent/tools/credentials/vaultwarden.md +382 -0
- package/.agent/tools/data-extraction/outscraper.md +974 -0
- package/.agent/tools/deployment/coolify-cli.md +388 -0
- package/.agent/tools/deployment/coolify-setup.md +353 -0
- package/.agent/tools/deployment/coolify.md +345 -0
- package/.agent/tools/deployment/vercel.md +390 -0
- package/.agent/tools/git/authentication.md +132 -0
- package/.agent/tools/git/gitea-cli.md +193 -0
- package/.agent/tools/git/github-actions.md +207 -0
- package/.agent/tools/git/github-cli.md +223 -0
- package/.agent/tools/git/gitlab-cli.md +190 -0
- package/.agent/tools/git/opencode-github-security.md +350 -0
- package/.agent/tools/git/opencode-github.md +328 -0
- package/.agent/tools/git/opencode-gitlab.md +252 -0
- package/.agent/tools/git/security.md +196 -0
- package/.agent/tools/git.md +207 -0
- package/.agent/tools/opencode/oh-my-opencode.md +375 -0
- package/.agent/tools/opencode/opencode-anthropic-auth.md +446 -0
- package/.agent/tools/opencode/opencode.md +651 -0
- package/.agent/tools/social-media/bird.md +437 -0
- package/.agent/tools/task-management/beads.md +336 -0
- package/.agent/tools/terminal/terminal-title.md +251 -0
- package/.agent/tools/ui/shadcn.md +196 -0
- package/.agent/tools/ui/ui-skills.md +115 -0
- package/.agent/tools/wordpress/localwp.md +311 -0
- package/.agent/tools/wordpress/mainwp.md +391 -0
- package/.agent/tools/wordpress/scf.md +527 -0
- package/.agent/tools/wordpress/wp-admin.md +729 -0
- package/.agent/tools/wordpress/wp-dev.md +940 -0
- package/.agent/tools/wordpress/wp-preferred.md +398 -0
- package/.agent/tools/wordpress.md +95 -0
- package/.agent/workflows/branch/bugfix.md +63 -0
- package/.agent/workflows/branch/chore.md +95 -0
- package/.agent/workflows/branch/experiment.md +115 -0
- package/.agent/workflows/branch/feature.md +59 -0
- package/.agent/workflows/branch/hotfix.md +98 -0
- package/.agent/workflows/branch/refactor.md +92 -0
- package/.agent/workflows/branch/release.md +96 -0
- package/.agent/workflows/branch.md +347 -0
- package/.agent/workflows/bug-fixing.md +267 -0
- package/.agent/workflows/changelog.md +129 -0
- package/.agent/workflows/code-audit-remote.md +279 -0
- package/.agent/workflows/conversation-starter.md +69 -0
- package/.agent/workflows/error-feedback.md +578 -0
- package/.agent/workflows/feature-development.md +355 -0
- package/.agent/workflows/git-workflow.md +702 -0
- package/.agent/workflows/multi-repo-workspace.md +268 -0
- package/.agent/workflows/plans.md +709 -0
- package/.agent/workflows/postflight.md +604 -0
- package/.agent/workflows/pr.md +571 -0
- package/.agent/workflows/preflight.md +278 -0
- package/.agent/workflows/ralph-loop.md +773 -0
- package/.agent/workflows/release.md +498 -0
- package/.agent/workflows/session-manager.md +254 -0
- package/.agent/workflows/session-review.md +311 -0
- package/.agent/workflows/sql-migrations.md +631 -0
- package/.agent/workflows/version-bump.md +283 -0
- package/.agent/workflows/wiki-update.md +333 -0
- package/.agent/workflows/worktree.md +477 -0
- package/LICENSE +21 -0
- package/README.md +1446 -0
- package/VERSION +1 -0
- package/aidevops.sh +1746 -0
- package/bin/aidevops +21 -0
- package/package.json +75 -0
- package/scripts/npm-postinstall.js +60 -0
- package/setup.sh +2366 -0
|
@@ -0,0 +1,847 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# shellcheck disable=SC2034,SC2155,SC2317,SC2329,SC2016,SC2181,SC1091,SC2154,SC2015,SC2086,SC2129,SC2030,SC2031,SC2119,SC2120,SC2001,SC2162,SC2088,SC2089,SC2090,SC2029,SC2006,SC2153
|
|
3
|
+
|
|
4
|
+
# Secretlint Integration Script
|
|
5
|
+
# Pluggable linting tool to prevent committing credentials and secrets
|
|
6
|
+
#
|
|
7
|
+
# Usage: ./secretlint-helper.sh [command] [options]
|
|
8
|
+
# Commands:
|
|
9
|
+
# install - Install Secretlint and recommended rules
|
|
10
|
+
# init - Initialize project configuration
|
|
11
|
+
# scan - Scan for secrets (alias for lint)
|
|
12
|
+
# lint - Lint files for secrets
|
|
13
|
+
# mask - Mask secrets in a file
|
|
14
|
+
# status - Check installation and configuration
|
|
15
|
+
# fix - Mask secrets and fix files in place
|
|
16
|
+
# quick - Quick scan without installation (npx)
|
|
17
|
+
# docker - Run scan via Docker
|
|
18
|
+
# help - Show this help message
|
|
19
|
+
#
|
|
20
|
+
# Author: AI DevOps Framework
|
|
21
|
+
# Version: 1.0.0
|
|
22
|
+
# License: MIT
|
|
23
|
+
# Reference: https://github.com/secretlint/secretlint
|
|
24
|
+
|
|
25
|
+
# Colors for output
|
|
26
|
+
readonly GREEN='\033[0;32m'
|
|
27
|
+
readonly BLUE='\033[0;34m'
|
|
28
|
+
readonly YELLOW='\033[1;33m'
|
|
29
|
+
readonly RED='\033[0;31m'
|
|
30
|
+
readonly PURPLE='\033[0;35m'
|
|
31
|
+
readonly CYAN='\033[0;36m'
|
|
32
|
+
readonly NC='\033[0m' # No Color
|
|
33
|
+
|
|
34
|
+
# Common constants
|
|
35
|
+
readonly ERROR_UNKNOWN_COMMAND="Unknown command:"
|
|
36
|
+
readonly SECRETLINT_CONFIG_FILE=".secretlintrc.json"
|
|
37
|
+
readonly SECRETLINT_IGNORE_FILE=".secretlintignore"
|
|
38
|
+
readonly DEFAULT_GLOB_PATTERN="**/*"
|
|
39
|
+
|
|
40
|
+
# Print functions
|
|
41
|
+
print_success() {
|
|
42
|
+
local message="$1"
|
|
43
|
+
echo -e "${GREEN}✅ $message${NC}"
|
|
44
|
+
return 0
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
print_info() {
|
|
48
|
+
local message="$1"
|
|
49
|
+
echo -e "${BLUE}ℹ️ $message${NC}"
|
|
50
|
+
return 0
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
print_warning() {
|
|
54
|
+
local message="$1"
|
|
55
|
+
echo -e "${YELLOW}⚠️ $message${NC}"
|
|
56
|
+
return 0
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
print_error() {
|
|
60
|
+
local message="$1"
|
|
61
|
+
echo -e "${RED}❌ $message${NC}" >&2
|
|
62
|
+
return 0
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
print_header() {
|
|
66
|
+
local message="$1"
|
|
67
|
+
echo -e "${PURPLE}🔐 $message${NC}"
|
|
68
|
+
return 0
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
print_secret() {
|
|
72
|
+
local message="$1"
|
|
73
|
+
echo -e "${CYAN}🛡️ $message${NC}"
|
|
74
|
+
return 0
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
# Check if Secretlint is installed
|
|
78
|
+
check_secretlint_installed() {
|
|
79
|
+
if command -v secretlint &> /dev/null; then
|
|
80
|
+
local version
|
|
81
|
+
version=$(secretlint --version 2>/dev/null || echo "unknown")
|
|
82
|
+
print_success "Secretlint installed: v$version"
|
|
83
|
+
return 0
|
|
84
|
+
elif [[ -f "node_modules/.bin/secretlint" ]]; then
|
|
85
|
+
local version
|
|
86
|
+
version=$(./node_modules/.bin/secretlint --version 2>/dev/null || echo "unknown")
|
|
87
|
+
print_success "Secretlint installed (local): v$version"
|
|
88
|
+
return 0
|
|
89
|
+
else
|
|
90
|
+
print_warning "Secretlint not found"
|
|
91
|
+
return 1
|
|
92
|
+
fi
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
# Check if Docker is available
|
|
96
|
+
check_docker_available() {
|
|
97
|
+
if command -v docker &> /dev/null; then
|
|
98
|
+
print_success "Docker available"
|
|
99
|
+
return 0
|
|
100
|
+
else
|
|
101
|
+
print_warning "Docker not found"
|
|
102
|
+
return 1
|
|
103
|
+
fi
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
# Get secretlint command (global or local)
|
|
107
|
+
get_secretlint_cmd() {
|
|
108
|
+
if command -v secretlint &> /dev/null; then
|
|
109
|
+
echo "secretlint"
|
|
110
|
+
elif [[ -f "node_modules/.bin/secretlint" ]]; then
|
|
111
|
+
echo "./node_modules/.bin/secretlint"
|
|
112
|
+
else
|
|
113
|
+
echo "npx secretlint"
|
|
114
|
+
fi
|
|
115
|
+
return 0
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
# Install Secretlint and recommended rules
|
|
119
|
+
install_secretlint() {
|
|
120
|
+
local install_type="${1:-local}"
|
|
121
|
+
|
|
122
|
+
print_header "Installing Secretlint"
|
|
123
|
+
|
|
124
|
+
# Check for Node.js
|
|
125
|
+
if ! command -v node &> /dev/null; then
|
|
126
|
+
print_error "Node.js is required. Please install Node.js 20+ first."
|
|
127
|
+
print_info "Alternatively, use Docker: $0 docker scan"
|
|
128
|
+
return 1
|
|
129
|
+
fi
|
|
130
|
+
|
|
131
|
+
local node_version
|
|
132
|
+
node_version=$(node -v | sed 's/v//' | cut -d. -f1)
|
|
133
|
+
if [[ $node_version -lt 18 ]]; then
|
|
134
|
+
print_warning "Node.js 20+ recommended. Current version: $(node -v)"
|
|
135
|
+
fi
|
|
136
|
+
|
|
137
|
+
case "$install_type" in
|
|
138
|
+
"global")
|
|
139
|
+
print_info "Installing Secretlint globally..."
|
|
140
|
+
npm install -g secretlint @secretlint/secretlint-rule-preset-recommend
|
|
141
|
+
;;
|
|
142
|
+
"local"|*)
|
|
143
|
+
print_info "Installing Secretlint locally..."
|
|
144
|
+
npm install --save-dev secretlint @secretlint/secretlint-rule-preset-recommend
|
|
145
|
+
;;
|
|
146
|
+
esac
|
|
147
|
+
|
|
148
|
+
if [[ $? -eq 0 ]]; then
|
|
149
|
+
print_success "Secretlint installed successfully"
|
|
150
|
+
|
|
151
|
+
# Initialize if config doesn't exist
|
|
152
|
+
if [[ ! -f "$SECRETLINT_CONFIG_FILE" ]]; then
|
|
153
|
+
print_info "Initializing configuration..."
|
|
154
|
+
init_secretlint_config
|
|
155
|
+
fi
|
|
156
|
+
|
|
157
|
+
return 0
|
|
158
|
+
else
|
|
159
|
+
print_error "Installation failed"
|
|
160
|
+
return 1
|
|
161
|
+
fi
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
# Install additional rules
|
|
165
|
+
install_additional_rules() {
|
|
166
|
+
local rules="${1:-pattern}"
|
|
167
|
+
|
|
168
|
+
print_header "Installing Additional Secretlint Rules"
|
|
169
|
+
|
|
170
|
+
local npm_cmd="npm install --save-dev"
|
|
171
|
+
if command -v secretlint &> /dev/null; then
|
|
172
|
+
npm_cmd="npm install -g"
|
|
173
|
+
fi
|
|
174
|
+
|
|
175
|
+
case "$rules" in
|
|
176
|
+
"pattern")
|
|
177
|
+
print_info "Installing custom pattern rule..."
|
|
178
|
+
$npm_cmd @secretlint/secretlint-rule-pattern
|
|
179
|
+
;;
|
|
180
|
+
"sarif")
|
|
181
|
+
print_info "Installing SARIF formatter..."
|
|
182
|
+
$npm_cmd @secretlint/secretlint-formatter-sarif
|
|
183
|
+
;;
|
|
184
|
+
"all")
|
|
185
|
+
print_info "Installing all recommended additional rules..."
|
|
186
|
+
$npm_cmd @secretlint/secretlint-rule-pattern \
|
|
187
|
+
@secretlint/secretlint-rule-no-k8s-kind-secret \
|
|
188
|
+
@secretlint/secretlint-rule-no-homedir \
|
|
189
|
+
@secretlint/secretlint-rule-no-dotenv \
|
|
190
|
+
@secretlint/secretlint-formatter-sarif
|
|
191
|
+
;;
|
|
192
|
+
*)
|
|
193
|
+
print_info "Installing rule: $rules"
|
|
194
|
+
$npm_cmd "$rules"
|
|
195
|
+
;;
|
|
196
|
+
esac
|
|
197
|
+
|
|
198
|
+
if [[ $? -eq 0 ]]; then
|
|
199
|
+
print_success "Additional rules installed"
|
|
200
|
+
return 0
|
|
201
|
+
else
|
|
202
|
+
print_error "Failed to install rules"
|
|
203
|
+
return 1
|
|
204
|
+
fi
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
# Initialize Secretlint configuration
|
|
208
|
+
init_secretlint_config() {
|
|
209
|
+
print_header "Initializing Secretlint Configuration"
|
|
210
|
+
|
|
211
|
+
local cmd
|
|
212
|
+
cmd=$(get_secretlint_cmd)
|
|
213
|
+
|
|
214
|
+
if [[ -f "$SECRETLINT_CONFIG_FILE" ]]; then
|
|
215
|
+
print_warning "Configuration already exists: $SECRETLINT_CONFIG_FILE"
|
|
216
|
+
print_info "Use 'secretlint --init' to overwrite"
|
|
217
|
+
return 0
|
|
218
|
+
fi
|
|
219
|
+
|
|
220
|
+
# Try to use secretlint --init
|
|
221
|
+
if $cmd --init &>/dev/null; then
|
|
222
|
+
print_success "Configuration initialized: $SECRETLINT_CONFIG_FILE"
|
|
223
|
+
else
|
|
224
|
+
# Manually create comprehensive config
|
|
225
|
+
print_info "Creating comprehensive configuration..."
|
|
226
|
+
create_comprehensive_config
|
|
227
|
+
fi
|
|
228
|
+
|
|
229
|
+
# Create ignore file if it doesn't exist
|
|
230
|
+
if [[ ! -f "$SECRETLINT_IGNORE_FILE" ]]; then
|
|
231
|
+
create_ignore_file
|
|
232
|
+
fi
|
|
233
|
+
|
|
234
|
+
return 0
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
# Create comprehensive configuration
|
|
238
|
+
create_comprehensive_config() {
|
|
239
|
+
cat > "$SECRETLINT_CONFIG_FILE" << 'EOF'
|
|
240
|
+
{
|
|
241
|
+
"rules": [
|
|
242
|
+
{
|
|
243
|
+
"id": "@secretlint/secretlint-rule-preset-recommend",
|
|
244
|
+
"rules": [
|
|
245
|
+
{
|
|
246
|
+
"id": "@secretlint/secretlint-rule-aws",
|
|
247
|
+
"options": {
|
|
248
|
+
"allows": []
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
"id": "@secretlint/secretlint-rule-github",
|
|
253
|
+
"options": {
|
|
254
|
+
"allows": []
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
"id": "@secretlint/secretlint-rule-privatekey"
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
"id": "@secretlint/secretlint-rule-basicauth"
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
"id": "@secretlint/secretlint-rule-slack"
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
"id": "@secretlint/secretlint-rule-sendgrid"
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
"id": "@secretlint/secretlint-rule-openai"
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
"id": "@secretlint/secretlint-rule-anthropic"
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
"id": "@secretlint/secretlint-rule-gcp"
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
"id": "@secretlint/secretlint-rule-npm"
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
"id": "@secretlint/secretlint-rule-shopify"
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
"id": "@secretlint/secretlint-rule-linear"
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
"id": "@secretlint/secretlint-rule-1password"
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
"id": "@secretlint/secretlint-rule-database-connection-string"
|
|
292
|
+
}
|
|
293
|
+
]
|
|
294
|
+
}
|
|
295
|
+
]
|
|
296
|
+
}
|
|
297
|
+
EOF
|
|
298
|
+
print_success "Created comprehensive configuration: $SECRETLINT_CONFIG_FILE"
|
|
299
|
+
return 0
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
# Create ignore file
|
|
303
|
+
create_ignore_file() {
|
|
304
|
+
cat > "$SECRETLINT_IGNORE_FILE" << 'EOF'
|
|
305
|
+
# Secretlint Ignore File
|
|
306
|
+
# Uses .gitignore syntax
|
|
307
|
+
|
|
308
|
+
# Dependencies
|
|
309
|
+
**/node_modules/**
|
|
310
|
+
**/vendor/**
|
|
311
|
+
**/.venv/**
|
|
312
|
+
**/venv/**
|
|
313
|
+
|
|
314
|
+
# Build outputs
|
|
315
|
+
**/dist/**
|
|
316
|
+
**/build/**
|
|
317
|
+
**/.next/**
|
|
318
|
+
**/out/**
|
|
319
|
+
|
|
320
|
+
# IDE and editor
|
|
321
|
+
**/.idea/**
|
|
322
|
+
**/.vscode/**
|
|
323
|
+
**/.vs/**
|
|
324
|
+
*.swp
|
|
325
|
+
*.swo
|
|
326
|
+
|
|
327
|
+
# Git
|
|
328
|
+
**/.git/**
|
|
329
|
+
|
|
330
|
+
# Test fixtures (may contain fake secrets for testing)
|
|
331
|
+
**/test/fixtures/**
|
|
332
|
+
**/tests/fixtures/**
|
|
333
|
+
**/__tests__/fixtures/**
|
|
334
|
+
**/testdata/**
|
|
335
|
+
|
|
336
|
+
# Generated files
|
|
337
|
+
**/*.min.js
|
|
338
|
+
**/*.min.css
|
|
339
|
+
**/package-lock.json
|
|
340
|
+
**/pnpm-lock.yaml
|
|
341
|
+
**/yarn.lock
|
|
342
|
+
**/composer.lock
|
|
343
|
+
**/Gemfile.lock
|
|
344
|
+
**/Cargo.lock
|
|
345
|
+
**/poetry.lock
|
|
346
|
+
|
|
347
|
+
# Documentation and examples (review manually if needed)
|
|
348
|
+
**/docs/**
|
|
349
|
+
**/examples/**
|
|
350
|
+
|
|
351
|
+
# Binary files
|
|
352
|
+
**/*.png
|
|
353
|
+
**/*.jpg
|
|
354
|
+
**/*.jpeg
|
|
355
|
+
**/*.gif
|
|
356
|
+
**/*.ico
|
|
357
|
+
**/*.svg
|
|
358
|
+
**/*.woff
|
|
359
|
+
**/*.woff2
|
|
360
|
+
**/*.ttf
|
|
361
|
+
**/*.eot
|
|
362
|
+
**/*.pdf
|
|
363
|
+
**/*.zip
|
|
364
|
+
**/*.tar
|
|
365
|
+
**/*.gz
|
|
366
|
+
**/*.rar
|
|
367
|
+
|
|
368
|
+
# Logs
|
|
369
|
+
**/*.log
|
|
370
|
+
**/logs/**
|
|
371
|
+
|
|
372
|
+
# Coverage reports
|
|
373
|
+
**/coverage/**
|
|
374
|
+
**/.nyc_output/**
|
|
375
|
+
|
|
376
|
+
# Cache
|
|
377
|
+
**/.cache/**
|
|
378
|
+
**/.tmp/**
|
|
379
|
+
**/tmp/**
|
|
380
|
+
EOF
|
|
381
|
+
print_success "Created ignore file: $SECRETLINT_IGNORE_FILE"
|
|
382
|
+
return 0
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
# Run Secretlint scan
|
|
386
|
+
run_secretlint_scan() {
|
|
387
|
+
local target="${1:-$DEFAULT_GLOB_PATTERN}"
|
|
388
|
+
local format="${2:-stylish}"
|
|
389
|
+
local output_file="$3"
|
|
390
|
+
local extra_args="$4"
|
|
391
|
+
|
|
392
|
+
print_header "Running Secretlint Scan"
|
|
393
|
+
|
|
394
|
+
# Validate target pattern for dangerous characters
|
|
395
|
+
if [[ "$target" == *";"* ]] || [[ "$target" == *"|"* ]] || [[ "$target" == *"&"* ]] || [[ "$target" == *"\`"* ]]; then
|
|
396
|
+
print_error "Invalid target pattern: contains forbidden characters"
|
|
397
|
+
return 1
|
|
398
|
+
fi
|
|
399
|
+
|
|
400
|
+
local cmd
|
|
401
|
+
cmd=$(get_secretlint_cmd)
|
|
402
|
+
|
|
403
|
+
# Check if configuration exists
|
|
404
|
+
if [[ ! -f "$SECRETLINT_CONFIG_FILE" ]]; then
|
|
405
|
+
print_warning "No configuration found. Initializing..."
|
|
406
|
+
init_secretlint_config
|
|
407
|
+
fi
|
|
408
|
+
|
|
409
|
+
# Build command array for safe execution
|
|
410
|
+
local -a cmd_array
|
|
411
|
+
read -ra cmd_array <<< "$cmd"
|
|
412
|
+
cmd_array+=("$target" "--format" "$format")
|
|
413
|
+
|
|
414
|
+
if [[ -n "$output_file" ]]; then
|
|
415
|
+
cmd_array+=("--output" "$output_file")
|
|
416
|
+
fi
|
|
417
|
+
|
|
418
|
+
# Handle extra_args safely by splitting on spaces (limited use case)
|
|
419
|
+
if [[ -n "$extra_args" ]]; then
|
|
420
|
+
read -ra extra_array <<< "$extra_args"
|
|
421
|
+
cmd_array+=("${extra_array[@]}")
|
|
422
|
+
fi
|
|
423
|
+
|
|
424
|
+
print_info "Scanning: $target"
|
|
425
|
+
print_info "Format: $format"
|
|
426
|
+
print_info "Command: ${cmd_array[*]}"
|
|
427
|
+
echo ""
|
|
428
|
+
|
|
429
|
+
# Execute scan using array (safe from injection)
|
|
430
|
+
"${cmd_array[@]}"
|
|
431
|
+
local exit_code=$?
|
|
432
|
+
|
|
433
|
+
echo ""
|
|
434
|
+
if [[ $exit_code -eq 0 ]]; then
|
|
435
|
+
print_success "No secrets detected! Your code is clean."
|
|
436
|
+
elif [[ $exit_code -eq 1 ]]; then
|
|
437
|
+
print_error "Secrets detected! Please review and remove/rotate exposed credentials."
|
|
438
|
+
print_info "Tip: Use 'secretlint-disable-line' comments to ignore false positives"
|
|
439
|
+
else
|
|
440
|
+
print_error "Scan failed with error code: $exit_code"
|
|
441
|
+
fi
|
|
442
|
+
|
|
443
|
+
return $exit_code
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
# Run quick scan via npx (no installation)
|
|
447
|
+
run_quick_scan() {
|
|
448
|
+
local target="${1:-$DEFAULT_GLOB_PATTERN}"
|
|
449
|
+
|
|
450
|
+
# Validate target pattern for dangerous characters
|
|
451
|
+
if [[ "$target" == *";"* ]] || [[ "$target" == *"|"* ]] || [[ "$target" == *"&"* ]] || [[ "$target" == *"\`"* ]]; then
|
|
452
|
+
print_error "Invalid target pattern: contains forbidden characters"
|
|
453
|
+
return 1
|
|
454
|
+
fi
|
|
455
|
+
|
|
456
|
+
print_header "Quick Secretlint Scan (via npx)"
|
|
457
|
+
print_info "This requires no installation"
|
|
458
|
+
|
|
459
|
+
npx @secretlint/quick-start "$target"
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
# Run scan via Docker
|
|
463
|
+
run_docker_scan() {
|
|
464
|
+
local target="${1:-$DEFAULT_GLOB_PATTERN}"
|
|
465
|
+
local extra_args="$2"
|
|
466
|
+
|
|
467
|
+
print_header "Running Secretlint via Docker"
|
|
468
|
+
|
|
469
|
+
# Validate target pattern for dangerous characters
|
|
470
|
+
if [[ "$target" == *";"* ]] || [[ "$target" == *"|"* ]] || [[ "$target" == *"&"* ]] || [[ "$target" == *"\`"* ]]; then
|
|
471
|
+
print_error "Invalid target pattern: contains forbidden characters"
|
|
472
|
+
return 1
|
|
473
|
+
fi
|
|
474
|
+
|
|
475
|
+
if ! check_docker_available; then
|
|
476
|
+
print_error "Docker is required for this command"
|
|
477
|
+
return 1
|
|
478
|
+
fi
|
|
479
|
+
|
|
480
|
+
local current_dir
|
|
481
|
+
current_dir=$(pwd)
|
|
482
|
+
|
|
483
|
+
# Build command array for safe execution
|
|
484
|
+
local -a cmd_array=(
|
|
485
|
+
"docker" "run"
|
|
486
|
+
"-v" "${current_dir}:${current_dir}"
|
|
487
|
+
"-w" "$current_dir"
|
|
488
|
+
"--rm" "-it"
|
|
489
|
+
"secretlint/secretlint"
|
|
490
|
+
"secretlint" "$target"
|
|
491
|
+
)
|
|
492
|
+
|
|
493
|
+
# Handle extra_args safely
|
|
494
|
+
if [[ -n "$extra_args" ]]; then
|
|
495
|
+
read -ra extra_array <<< "$extra_args"
|
|
496
|
+
cmd_array+=("${extra_array[@]}")
|
|
497
|
+
fi
|
|
498
|
+
|
|
499
|
+
print_info "Command: ${cmd_array[*]}"
|
|
500
|
+
echo ""
|
|
501
|
+
|
|
502
|
+
# Execute using array (safe from injection)
|
|
503
|
+
"${cmd_array[@]}"
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
# Mask secrets in a file
|
|
507
|
+
mask_secrets() {
|
|
508
|
+
local input_file="$1"
|
|
509
|
+
local output_file="${2:-$input_file}"
|
|
510
|
+
|
|
511
|
+
print_header "Masking Secrets"
|
|
512
|
+
|
|
513
|
+
if [[ -z "$input_file" ]]; then
|
|
514
|
+
print_error "Input file required"
|
|
515
|
+
print_info "Usage: $0 mask <input-file> [output-file]"
|
|
516
|
+
return 1
|
|
517
|
+
fi
|
|
518
|
+
|
|
519
|
+
if [[ ! -f "$input_file" ]]; then
|
|
520
|
+
print_error "File not found: $input_file"
|
|
521
|
+
return 1
|
|
522
|
+
fi
|
|
523
|
+
|
|
524
|
+
local cmd
|
|
525
|
+
cmd=$(get_secretlint_cmd)
|
|
526
|
+
|
|
527
|
+
print_info "Input: $input_file"
|
|
528
|
+
print_info "Output: $output_file"
|
|
529
|
+
|
|
530
|
+
$cmd "$input_file" --format=mask-result --output="$output_file"
|
|
531
|
+
|
|
532
|
+
if [[ $? -eq 0 ]]; then
|
|
533
|
+
print_success "Secrets masked successfully"
|
|
534
|
+
return 0
|
|
535
|
+
else
|
|
536
|
+
print_error "Failed to mask secrets"
|
|
537
|
+
return 1
|
|
538
|
+
fi
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
# Show status
|
|
542
|
+
show_status() {
|
|
543
|
+
print_header "Secretlint Status"
|
|
544
|
+
echo ""
|
|
545
|
+
|
|
546
|
+
# Check installation
|
|
547
|
+
print_info "Installation:"
|
|
548
|
+
check_secretlint_installed
|
|
549
|
+
check_docker_available
|
|
550
|
+
echo ""
|
|
551
|
+
|
|
552
|
+
# Check Node.js
|
|
553
|
+
print_info "Node.js:"
|
|
554
|
+
if command -v node &> /dev/null; then
|
|
555
|
+
print_success "Node.js: $(node -v)"
|
|
556
|
+
else
|
|
557
|
+
print_warning "Node.js: Not installed"
|
|
558
|
+
fi
|
|
559
|
+
echo ""
|
|
560
|
+
|
|
561
|
+
# Check configuration
|
|
562
|
+
print_info "Configuration:"
|
|
563
|
+
if [[ -f "$SECRETLINT_CONFIG_FILE" ]]; then
|
|
564
|
+
print_success "Config file: $SECRETLINT_CONFIG_FILE"
|
|
565
|
+
|
|
566
|
+
# Count rules
|
|
567
|
+
if command -v jq &> /dev/null; then
|
|
568
|
+
local rules_count
|
|
569
|
+
rules_count=$(jq -r '.rules | length' "$SECRETLINT_CONFIG_FILE" 2>/dev/null || echo "unknown")
|
|
570
|
+
print_info "Configured rule presets: $rules_count"
|
|
571
|
+
fi
|
|
572
|
+
else
|
|
573
|
+
print_warning "Config file: Not found"
|
|
574
|
+
print_info "Run: $0 init"
|
|
575
|
+
fi
|
|
576
|
+
|
|
577
|
+
if [[ -f "$SECRETLINT_IGNORE_FILE" ]]; then
|
|
578
|
+
print_success "Ignore file: $SECRETLINT_IGNORE_FILE"
|
|
579
|
+
local ignore_count
|
|
580
|
+
ignore_count=$(grep -cv '^#\|^$' "$SECRETLINT_IGNORE_FILE" 2>/dev/null || echo "0")
|
|
581
|
+
print_info "Ignore patterns: $ignore_count"
|
|
582
|
+
else
|
|
583
|
+
print_warning "Ignore file: Not found"
|
|
584
|
+
fi
|
|
585
|
+
echo ""
|
|
586
|
+
|
|
587
|
+
# Show available rules in preset
|
|
588
|
+
print_info "Recommended Rules (preset-recommend):"
|
|
589
|
+
echo " - AWS credentials (Access Key, Secret Key, Account ID)"
|
|
590
|
+
echo " - GCP credentials"
|
|
591
|
+
echo " - GitHub tokens (PAT, OAuth, App)"
|
|
592
|
+
echo " - npm tokens"
|
|
593
|
+
echo " - Private keys (RSA, DSA, EC, OpenSSH)"
|
|
594
|
+
echo " - Basic auth in URLs"
|
|
595
|
+
echo " - Slack tokens and webhooks"
|
|
596
|
+
echo " - SendGrid API keys"
|
|
597
|
+
echo " - Shopify API keys"
|
|
598
|
+
echo " - OpenAI API keys"
|
|
599
|
+
echo " - Anthropic/Claude API keys"
|
|
600
|
+
echo " - Linear API keys"
|
|
601
|
+
echo " - 1Password service account tokens"
|
|
602
|
+
echo " - Database connection strings"
|
|
603
|
+
echo ""
|
|
604
|
+
|
|
605
|
+
return 0
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
# Generate SARIF output
|
|
609
|
+
generate_sarif() {
|
|
610
|
+
local target="${1:-$DEFAULT_GLOB_PATTERN}"
|
|
611
|
+
local output_file="${2:-secretlint-results.sarif}"
|
|
612
|
+
|
|
613
|
+
print_header "Generating SARIF Output"
|
|
614
|
+
|
|
615
|
+
# Check if SARIF formatter is installed
|
|
616
|
+
if ! npm list @secretlint/secretlint-formatter-sarif &>/dev/null; then
|
|
617
|
+
print_info "Installing SARIF formatter..."
|
|
618
|
+
npm install --save-dev @secretlint/secretlint-formatter-sarif
|
|
619
|
+
fi
|
|
620
|
+
|
|
621
|
+
local cmd
|
|
622
|
+
cmd=$(get_secretlint_cmd)
|
|
623
|
+
|
|
624
|
+
$cmd "$target" --format @secretlint/secretlint-formatter-sarif > "$output_file"
|
|
625
|
+
|
|
626
|
+
if [[ $? -eq 0 ]]; then
|
|
627
|
+
print_success "SARIF output saved: $output_file"
|
|
628
|
+
return 0
|
|
629
|
+
else
|
|
630
|
+
print_error "Failed to generate SARIF output"
|
|
631
|
+
return 1
|
|
632
|
+
fi
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
# Pre-commit hook setup
|
|
636
|
+
setup_precommit_hook() {
|
|
637
|
+
print_header "Setting Up Pre-commit Hook"
|
|
638
|
+
|
|
639
|
+
local hook_file=".git/hooks/pre-commit"
|
|
640
|
+
local hook_dir=".git/hooks"
|
|
641
|
+
|
|
642
|
+
if [[ ! -d ".git" ]]; then
|
|
643
|
+
print_error "Not a git repository"
|
|
644
|
+
return 1
|
|
645
|
+
fi
|
|
646
|
+
|
|
647
|
+
mkdir -p "$hook_dir"
|
|
648
|
+
|
|
649
|
+
# Check if hook already exists
|
|
650
|
+
if [[ -f "$hook_file" ]]; then
|
|
651
|
+
if grep -q "secretlint" "$hook_file"; then
|
|
652
|
+
print_warning "Secretlint hook already configured"
|
|
653
|
+
return 0
|
|
654
|
+
else
|
|
655
|
+
print_warning "Pre-commit hook exists. Adding Secretlint..."
|
|
656
|
+
# Append to existing hook
|
|
657
|
+
cat >> "$hook_file" << 'EOF'
|
|
658
|
+
|
|
659
|
+
# Secretlint - Secret Detection
|
|
660
|
+
FILES=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g')
|
|
661
|
+
[ -z "$FILES" ] && exit 0
|
|
662
|
+
|
|
663
|
+
echo "Running Secretlint..."
|
|
664
|
+
echo "$FILES" | xargs npx secretlint
|
|
665
|
+
RET=$?
|
|
666
|
+
if [ $RET -ne 0 ]; then
|
|
667
|
+
echo "Secretlint found potential secrets. Please review before committing."
|
|
668
|
+
exit 1
|
|
669
|
+
fi
|
|
670
|
+
EOF
|
|
671
|
+
fi
|
|
672
|
+
else
|
|
673
|
+
# Create new hook
|
|
674
|
+
cat > "$hook_file" << 'EOF'
|
|
675
|
+
#!/bin/sh
|
|
676
|
+
# Pre-commit hook with Secretlint integration
|
|
677
|
+
|
|
678
|
+
# Secretlint - Secret Detection
|
|
679
|
+
FILES=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g')
|
|
680
|
+
[ -z "$FILES" ] && exit 0
|
|
681
|
+
|
|
682
|
+
echo "Running Secretlint..."
|
|
683
|
+
echo "$FILES" | xargs npx secretlint
|
|
684
|
+
RET=$?
|
|
685
|
+
if [ $RET -ne 0 ]; then
|
|
686
|
+
echo "Secretlint found potential secrets. Please review before committing."
|
|
687
|
+
exit 1
|
|
688
|
+
fi
|
|
689
|
+
|
|
690
|
+
exit 0
|
|
691
|
+
EOF
|
|
692
|
+
fi
|
|
693
|
+
|
|
694
|
+
chmod +x "$hook_file"
|
|
695
|
+
print_success "Pre-commit hook configured: $hook_file"
|
|
696
|
+
|
|
697
|
+
return 0
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
# Setup with Husky + lint-staged
|
|
701
|
+
setup_husky_integration() {
|
|
702
|
+
print_header "Setting Up Husky + lint-staged Integration"
|
|
703
|
+
|
|
704
|
+
if [[ ! -f "package.json" ]]; then
|
|
705
|
+
print_error "package.json not found. Initialize npm project first."
|
|
706
|
+
return 1
|
|
707
|
+
fi
|
|
708
|
+
|
|
709
|
+
print_info "Installing Husky and lint-staged..."
|
|
710
|
+
npx husky-init 2>/dev/null || npm install husky --save-dev
|
|
711
|
+
npm install lint-staged --save-dev
|
|
712
|
+
|
|
713
|
+
# Initialize Husky
|
|
714
|
+
npx husky install
|
|
715
|
+
|
|
716
|
+
# Add pre-commit hook
|
|
717
|
+
npx husky add .husky/pre-commit "npx --no-install lint-staged"
|
|
718
|
+
|
|
719
|
+
# Update package.json with lint-staged config
|
|
720
|
+
print_info "Adding lint-staged configuration to package.json..."
|
|
721
|
+
|
|
722
|
+
if command -v jq &> /dev/null; then
|
|
723
|
+
local tmp_file
|
|
724
|
+
tmp_file=$(mktemp)
|
|
725
|
+
jq '. + {"lint-staged": {"*": ["secretlint"]}}' package.json > "$tmp_file" && mv "$tmp_file" package.json
|
|
726
|
+
print_success "Added lint-staged configuration"
|
|
727
|
+
else
|
|
728
|
+
print_warning "jq not available. Please add manually to package.json:"
|
|
729
|
+
echo ' "lint-staged": {'
|
|
730
|
+
echo ' "*": ["secretlint"]'
|
|
731
|
+
echo ' }'
|
|
732
|
+
fi
|
|
733
|
+
|
|
734
|
+
print_success "Husky + lint-staged configured"
|
|
735
|
+
|
|
736
|
+
return 0
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
# Show help
|
|
740
|
+
show_help() {
|
|
741
|
+
print_header "Secretlint Helper - Secret Detection Tool"
|
|
742
|
+
echo ""
|
|
743
|
+
echo "Usage: $0 <command> [options]"
|
|
744
|
+
echo ""
|
|
745
|
+
echo "Commands:"
|
|
746
|
+
echo " install [local|global] - Install Secretlint and recommended rules"
|
|
747
|
+
echo " install-rules [rule] - Install additional rules (pattern|sarif|all|<pkg>)"
|
|
748
|
+
echo " init - Initialize project configuration"
|
|
749
|
+
echo " scan [target] [format] - Scan files for secrets"
|
|
750
|
+
echo " lint [target] [format] - Alias for scan"
|
|
751
|
+
echo " quick [target] - Quick scan via npx (no install)"
|
|
752
|
+
echo " docker [target] - Scan via Docker"
|
|
753
|
+
echo " mask <file> [output] - Mask secrets in a file"
|
|
754
|
+
echo " sarif [target] [output] - Generate SARIF output"
|
|
755
|
+
echo " hook - Setup git pre-commit hook"
|
|
756
|
+
echo " husky - Setup Husky + lint-staged"
|
|
757
|
+
echo " status - Show installation and configuration status"
|
|
758
|
+
echo " help - Show this help message"
|
|
759
|
+
echo ""
|
|
760
|
+
echo "Formats: stylish (default), json, compact, table, sarif, mask-result"
|
|
761
|
+
echo ""
|
|
762
|
+
echo "Examples:"
|
|
763
|
+
echo " $0 install # Install locally"
|
|
764
|
+
echo " $0 init # Initialize configuration"
|
|
765
|
+
echo " $0 scan # Scan all files"
|
|
766
|
+
echo " $0 scan \"src/**/*\" # Scan specific directory"
|
|
767
|
+
echo " $0 scan . json # Output as JSON"
|
|
768
|
+
echo " $0 quick # Quick scan (no install)"
|
|
769
|
+
echo " $0 docker # Scan via Docker"
|
|
770
|
+
echo " $0 mask .env.example # Mask secrets in file"
|
|
771
|
+
echo " $0 sarif # Generate SARIF for CI/CD"
|
|
772
|
+
echo " $0 hook # Setup pre-commit hook"
|
|
773
|
+
echo ""
|
|
774
|
+
echo "Environment Variables:"
|
|
775
|
+
echo " None required - Secretlint works offline"
|
|
776
|
+
echo ""
|
|
777
|
+
echo "Detected Secret Types:"
|
|
778
|
+
echo " - AWS credentials (Access Key, Secret Key)"
|
|
779
|
+
echo " - GCP service account keys"
|
|
780
|
+
echo " - GitHub tokens (PAT, OAuth, App, Actions)"
|
|
781
|
+
echo " - OpenAI/Anthropic API keys"
|
|
782
|
+
echo " - Private keys (RSA, DSA, EC, OpenSSH)"
|
|
783
|
+
echo " - Database connection strings"
|
|
784
|
+
echo " - Slack tokens and webhooks"
|
|
785
|
+
echo " - npm tokens"
|
|
786
|
+
echo " - And many more..."
|
|
787
|
+
echo ""
|
|
788
|
+
echo "Reference: https://github.com/secretlint/secretlint"
|
|
789
|
+
return 0
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
# Main function
|
|
793
|
+
main() {
|
|
794
|
+
local command="${1:-help}"
|
|
795
|
+
local arg2="${2:-}"
|
|
796
|
+
local arg3="${3:-}"
|
|
797
|
+
local arg4="${4:-}"
|
|
798
|
+
|
|
799
|
+
case "$command" in
|
|
800
|
+
"install")
|
|
801
|
+
install_secretlint "$arg2"
|
|
802
|
+
;;
|
|
803
|
+
"install-rules")
|
|
804
|
+
install_additional_rules "$arg2"
|
|
805
|
+
;;
|
|
806
|
+
"init")
|
|
807
|
+
init_secretlint_config
|
|
808
|
+
;;
|
|
809
|
+
"scan"|"lint")
|
|
810
|
+
run_secretlint_scan "$arg2" "$arg3" "$arg4"
|
|
811
|
+
;;
|
|
812
|
+
"quick")
|
|
813
|
+
run_quick_scan "$arg2"
|
|
814
|
+
;;
|
|
815
|
+
"docker")
|
|
816
|
+
run_docker_scan "$arg2" "$arg3"
|
|
817
|
+
;;
|
|
818
|
+
"mask"|"fix")
|
|
819
|
+
mask_secrets "$arg2" "$arg3"
|
|
820
|
+
;;
|
|
821
|
+
"sarif")
|
|
822
|
+
generate_sarif "$arg2" "$arg3"
|
|
823
|
+
;;
|
|
824
|
+
"hook")
|
|
825
|
+
setup_precommit_hook
|
|
826
|
+
;;
|
|
827
|
+
"husky")
|
|
828
|
+
setup_husky_integration
|
|
829
|
+
;;
|
|
830
|
+
"status")
|
|
831
|
+
show_status
|
|
832
|
+
;;
|
|
833
|
+
"help"|"--help"|"-h")
|
|
834
|
+
show_help
|
|
835
|
+
;;
|
|
836
|
+
*)
|
|
837
|
+
print_error "$ERROR_UNKNOWN_COMMAND $command"
|
|
838
|
+
echo ""
|
|
839
|
+
show_help
|
|
840
|
+
return 1
|
|
841
|
+
;;
|
|
842
|
+
esac
|
|
843
|
+
return $?
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
# Execute main function with all arguments
|
|
847
|
+
main "$@"
|