git-cli-scanner 1.4.0 → 1.5.0

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.
Files changed (2) hide show
  1. package/dist/cli.js +274 -2
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -229,6 +229,20 @@ var init_cloudProviders = __esm({
229
229
  pattern: /AIza[0-9A-Za-z\-_]{35}/,
230
230
  risk: "Attackers can bypass quotas to abuse GCP services like Maps API or Vertex AI, causing high billing charges.",
231
231
  solution: "Restrict the key in Google Cloud Console (APIs & Services > Credentials) to specific IP addresses/apps, or revoke it and use GCP Service Accounts."
232
+ },
233
+ {
234
+ id: "firebase-secret",
235
+ description: "Firebase API Key or Secret",
236
+ pattern: /firebase[_-]?(?:api[_-]?key|secret)[\s:=]+["'][a-zA-Z0-9\-_]{30,}["']/i,
237
+ risk: "Attackers can bypass security rules, read/write to your Firebase database, or exhaust quotas.",
238
+ solution: "Revoke the key in the Firebase console and restrict new keys to specific domains or IP addresses."
239
+ },
240
+ {
241
+ id: "firebase-service-account",
242
+ description: "Firebase Service Account JSON (Heuristic)",
243
+ pattern: /"type"\s*:\s*"service_account"|-----BEGIN PRIVATE KEY-----/i,
244
+ risk: "Service accounts grant full administrative access to your Firebase project, including databases, auth, and storage.",
245
+ solution: "Delete the service account key in Google Cloud IAM and never commit service account JSON files. Use environment variables."
232
246
  }
233
247
  ];
234
248
  cloudProviderScanner = {
@@ -397,7 +411,7 @@ var init_envFiles = __esm({
397
411
  scan(diff) {
398
412
  const issues = [];
399
413
  const filename = diff.file.split("/").pop() || "";
400
- const bannedExtensions = [".pem", ".key", ".sqlite", ".db", ".log", ".p12", ".pfx"];
414
+ const bannedExtensions = [".pem", ".key", ".sqlite", ".db", ".log", ".p12", ".pfx", ".crt", ".cer", ".keystore"];
401
415
  const isEnvFile = /(^|\/)\.env(\..+)?$/.test(diff.file);
402
416
  const isNodeModules = diff.file.startsWith("node_modules/");
403
417
  if (isEnvFile || isNodeModules || bannedExtensions.some((ext) => diff.file.endsWith(ext))) {
@@ -458,6 +472,20 @@ var init_infrastructure = __esm({
458
472
  pattern: /(?:postgres|mysql|mongodb(?:\+srv)?|redis):\/\/[^:\/\s]+:[^@\/\s]+@[^:\/\s]+(?::\d+)?\//,
459
473
  risk: "An attacker can directly connect to your database instance, allowing them to steal, modify, or delete all of your user data.",
460
474
  solution: "Remove the hardcoded database URL and read it from an environment variable (e.g., process.env.DATABASE_URL) at runtime."
475
+ },
476
+ {
477
+ id: "smtp-credentials",
478
+ description: "SMTP Email Credentials",
479
+ pattern: /(?:smtp|mail|sendgrid|mailgun)[\w\-]*(?:password|secret|key)[\s:=]+["'][^"'\s]+["']/i,
480
+ risk: "Attackers can use your SMTP server to send spam or phishing emails, ruining your domain reputation and incurring massive costs.",
481
+ solution: "Change the SMTP password via your email provider and inject it securely using a secrets manager."
482
+ },
483
+ {
484
+ id: "terraform-helm-secret",
485
+ description: "Terraform / Helm Variable Secret",
486
+ pattern: /(?:tf_var|helm_var)_[a-zA-Z0-9_]+[\s:=]+["'][^"'\s]+["']/i,
487
+ risk: "Hardcoded infrastructure secrets can grant access to the underlying platform resources and services.",
488
+ solution: "Use a proper secrets management backend for Terraform (e.g. Vault) or pass secrets via CI/CD runners."
461
489
  }
462
490
  ];
463
491
  infrastructureScanner = {
@@ -491,6 +519,242 @@ var init_infrastructure = __esm({
491
519
  }
492
520
  });
493
521
 
522
+ // src/scans/authentication.ts
523
+ var rules6, authenticationScanner;
524
+ var init_authentication = __esm({
525
+ "src/scans/authentication.ts"() {
526
+ "use strict";
527
+ rules6 = [
528
+ {
529
+ id: "jwt-secret",
530
+ description: "JWT Secret Key",
531
+ pattern: /(?:jwt[_-]?(?:secret|key)|secret[_-]?key)[\s:=]+[\"'][a-zA-Z0-9\-_!@#$%^&*()=+]{16,}[\"']/i,
532
+ risk: "An attacker can forge JWT tokens to impersonate any user, including admins, bypassing all authentication.",
533
+ solution: "Rotate the secret, ensure all existing JWT sessions are invalidated, and inject it via environment variables."
534
+ },
535
+ {
536
+ id: "oauth-client-secret",
537
+ description: "OAuth Client Secret",
538
+ pattern: /(?:oauth|client)[_-]?(?:secret|key)[\s:=]+[\"'][a-zA-Z0-9\-_]{16,}[\"']/i,
539
+ risk: "Attackers can hijack the OAuth flow, authenticate on behalf of your users, or exhaust API quotas.",
540
+ solution: "Revoke the OAuth client secret in the identity provider console and generate a new one."
541
+ },
542
+ {
543
+ id: "session-secret",
544
+ description: "Session Cookie Secret",
545
+ pattern: /(?:session)[_-]?(?:secret|key)[\s:=]+[\"'][a-zA-Z0-9\-_!@#$%^&*()=+]{16,}[\"']/i,
546
+ risk: "Attackers can forge signed session cookies, allowing them to hijack active user sessions.",
547
+ solution: "Change the session secret to immediately invalidate all current user sessions."
548
+ }
549
+ ];
550
+ authenticationScanner = {
551
+ id: "authentication",
552
+ scan(diff) {
553
+ const issues = [];
554
+ const lines = diff.content.split("\n");
555
+ let lineNumber = 1;
556
+ for (const line of lines) {
557
+ if (line.startsWith("+")) {
558
+ const cleanLine = line.substring(1);
559
+ for (const rule of rules6) {
560
+ if (rule.pattern.test(cleanLine)) {
561
+ issues.push({
562
+ type: rule.id,
563
+ file: diff.file,
564
+ line: lineNumber,
565
+ match: cleanLine.trim().substring(0, 50) + "...",
566
+ severity: "high",
567
+ solution: rule.solution,
568
+ risk: rule.risk
569
+ });
570
+ }
571
+ }
572
+ }
573
+ lineNumber++;
574
+ }
575
+ return issues;
576
+ }
577
+ };
578
+ }
579
+ });
580
+
581
+ // src/scans/packageRegistries.ts
582
+ var rules7, packageRegistryScanner;
583
+ var init_packageRegistries = __esm({
584
+ "src/scans/packageRegistries.ts"() {
585
+ "use strict";
586
+ rules7 = [
587
+ {
588
+ id: "npm-token",
589
+ description: "NPM Access Token",
590
+ pattern: /(?:npm|NPM)[_-]?(?:token|TOKEN)[\s:=]+["'](?:npm_[a-zA-Z0-9]{36})["']/i,
591
+ risk: "Attackers can publish malicious versions of your packages (Supply Chain Attack) to compromise all users downloading your code.",
592
+ solution: "Revoke the token immediately on npmjs.com and check your package versions for unauthorized releases."
593
+ },
594
+ {
595
+ id: "pypi-token",
596
+ description: "PyPI Access Token",
597
+ pattern: /pypi-[a-zA-Z0-9_-]{50,}/,
598
+ risk: "Attackers can upload malicious packages to PyPI under your name, distributing malware to your downstream users.",
599
+ solution: "Revoke the token in your PyPI account settings immediately and inspect recent package uploads."
600
+ },
601
+ {
602
+ id: "maven-gradle-password",
603
+ description: "Maven/Gradle Repository Password",
604
+ pattern: /(?:maven|gradle|nexus|artifactory)[\w\-]*password[\s:=]+["'][a-zA-Z0-9\-_!@#$%^&*()=+]{8,}["']/i,
605
+ risk: "Attackers can access your private artifact repository, steal proprietary code, or inject backdoors into your Java packages.",
606
+ solution: "Change your repository password and remove it from the hardcoded configuration file (e.g. settings.xml)."
607
+ }
608
+ ];
609
+ packageRegistryScanner = {
610
+ id: "package-registries",
611
+ scan(diff) {
612
+ const issues = [];
613
+ const lines = diff.content.split("\n");
614
+ let lineNumber = 1;
615
+ for (const line of lines) {
616
+ if (line.startsWith("+")) {
617
+ const cleanLine = line.substring(1);
618
+ for (const rule of rules7) {
619
+ if (rule.pattern.test(cleanLine)) {
620
+ issues.push({
621
+ type: rule.id,
622
+ file: diff.file,
623
+ line: lineNumber,
624
+ match: cleanLine.trim().substring(0, 50) + "...",
625
+ severity: "high",
626
+ solution: rule.solution,
627
+ risk: rule.risk
628
+ });
629
+ }
630
+ }
631
+ }
632
+ lineNumber++;
633
+ }
634
+ return issues;
635
+ }
636
+ };
637
+ }
638
+ });
639
+
640
+ // src/scans/cicd.ts
641
+ var rules8, cicdScanner;
642
+ var init_cicd = __esm({
643
+ "src/scans/cicd.ts"() {
644
+ "use strict";
645
+ rules8 = [
646
+ {
647
+ id: "gitlab-ci-token",
648
+ description: "GitLab Personal Access Token",
649
+ pattern: /glpat-[a-zA-Z0-9\-]{20,}/,
650
+ risk: "Attackers can access your GitLab repositories, modify CI/CD pipelines, and steal sensitive code or deployment secrets.",
651
+ solution: "Revoke the token in your GitLab account (User Settings > Access Tokens) and use environment variables for CI authentication."
652
+ },
653
+ {
654
+ id: "github-actions-token",
655
+ description: "GitHub Actions Token / Fine-grained PAT",
656
+ pattern: /gh[p|a|s|r]_[a-zA-Z0-9]{36}/,
657
+ risk: "Compromised GitHub tokens can allow attackers to push code, trigger malicious Actions workflows, or steal repository secrets.",
658
+ solution: "Revoke the token immediately in GitHub (Settings > Developer Settings) and switch to short-lived GitHub App tokens if possible."
659
+ },
660
+ {
661
+ id: "jenkins-token",
662
+ description: "Jenkins Token or API Secret",
663
+ pattern: /(?:jenkins)[\w\-]*(?:token|secret|password)[\s:=]+["'][a-zA-Z0-9]{32}["']/i,
664
+ risk: "Attackers can trigger or modify your Jenkins build pipelines, leading to malicious deployments or lateral movement.",
665
+ solution: "Revoke the API token in the Jenkins User Configuration page and inject secrets using the Jenkins Credentials Manager."
666
+ }
667
+ ];
668
+ cicdScanner = {
669
+ id: "cicd-secrets",
670
+ scan(diff) {
671
+ const issues = [];
672
+ const lines = diff.content.split("\n");
673
+ let lineNumber = 1;
674
+ for (const line of lines) {
675
+ if (line.startsWith("+")) {
676
+ const cleanLine = line.substring(1);
677
+ for (const rule of rules8) {
678
+ if (rule.pattern.test(cleanLine)) {
679
+ issues.push({
680
+ type: rule.id,
681
+ file: diff.file,
682
+ line: lineNumber,
683
+ match: cleanLine.trim().substring(0, 50) + "...",
684
+ severity: "critical",
685
+ solution: rule.solution,
686
+ risk: rule.risk
687
+ });
688
+ }
689
+ }
690
+ }
691
+ lineNumber++;
692
+ }
693
+ return issues;
694
+ }
695
+ };
696
+ }
697
+ });
698
+
699
+ // src/scans/webhooks.ts
700
+ var rules9, webhooksScanner;
701
+ var init_webhooks = __esm({
702
+ "src/scans/webhooks.ts"() {
703
+ "use strict";
704
+ rules9 = [
705
+ {
706
+ id: "stripe-secret",
707
+ description: "Stripe Secret Key / Webhook Secret",
708
+ pattern: /(?:sk_live|rk_live|whsec)_[a-zA-Z0-9]{24,}/,
709
+ risk: "Attackers can process fraudulent transactions, issue refunds, or steal customer financial data from your Stripe account.",
710
+ solution: "Roll the secret key immediately in the Stripe Dashboard (Developers > API keys) and monitor recent charges."
711
+ },
712
+ {
713
+ id: "paypal-secret",
714
+ description: "PayPal Client Secret",
715
+ pattern: /paypal[_-]?(?:client[_-]?secret|secret)[\s:=]+["'][a-zA-Z0-9\-_]{30,}["']/i,
716
+ risk: "Attackers can process fraudulent payments, manipulate subscriptions, or steal transaction history.",
717
+ solution: "Revoke the secret in the PayPal Developer Dashboard and generate a new one."
718
+ },
719
+ {
720
+ id: "generic-webhook",
721
+ description: "Generic Webhook URL (Slack, Discord, etc)",
722
+ pattern: /(?:https?:\/\/)?(?:hooks\.slack\.com|discord\.com\/api\/webhooks|maker\.ifttt\.com)[^\s'"]+/i,
723
+ risk: "Attackers can spam your internal channels, launch phishing attacks on your team, or exhaust rate limits.",
724
+ solution: "Delete the webhook in the respective service platform and re-generate a new URL. Do not commit webhook URLs directly."
725
+ }
726
+ ];
727
+ webhooksScanner = {
728
+ id: "webhooks",
729
+ scan(diff) {
730
+ const issues = [];
731
+ const lines = diff.content.split("\n");
732
+ let lineNumber = 1;
733
+ for (const line of lines) {
734
+ if (line.startsWith("+")) {
735
+ const cleanLine = line.substring(1);
736
+ for (const rule of rules9) {
737
+ if (rule.pattern.test(cleanLine)) {
738
+ issues.push({
739
+ type: rule.id,
740
+ file: diff.file,
741
+ line: lineNumber,
742
+ match: cleanLine.trim().substring(0, 50) + "...",
743
+ severity: "high",
744
+ solution: rule.solution,
745
+ risk: rule.risk
746
+ });
747
+ }
748
+ }
749
+ }
750
+ lineNumber++;
751
+ }
752
+ return issues;
753
+ }
754
+ };
755
+ }
756
+ });
757
+
494
758
  // src/scans/index.ts
495
759
  var allScanners;
496
760
  var init_scans = __esm({
@@ -502,13 +766,21 @@ var init_scans = __esm({
502
766
  init_privateKeys();
503
767
  init_envFiles();
504
768
  init_infrastructure();
769
+ init_authentication();
770
+ init_packageRegistries();
771
+ init_cicd();
772
+ init_webhooks();
505
773
  allScanners = [
506
774
  apiKeyScanner,
507
775
  cloudProviderScanner,
508
776
  collaborationScanner,
509
777
  privateKeyScanner,
510
778
  envFileScanner,
511
- infrastructureScanner
779
+ infrastructureScanner,
780
+ authenticationScanner,
781
+ packageRegistryScanner,
782
+ cicdScanner,
783
+ webhooksScanner
512
784
  ];
513
785
  }
514
786
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "git-cli-scanner",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "A powerful interactive CLI tool that scans your codebase for hardcoded secrets, API keys, passwords, and private keys before they reach your Git history.",
5
5
  "main": "dist/cli.js",
6
6
  "scripts": {