From 9701bf1724d822c0d5bbb7627535dd639a37bf56 Mon Sep 17 00:00:00 2001 From: Rafael Figueiredo Date: Tue, 21 Mar 2023 06:50:34 -0700 Subject: [PATCH] Bufix/1100 protect stagged files (#1121) * create repo with stagged secrets * add .gitleaksignore to testdata repo * fix typo * add gitleaksignore to detector on protect command --------- Co-authored-by: Rafael Figueiredo --- cmd/protect.go | 7 +- detect/detect_test.go | 81 ++++++++++++++++++ testdata/repos/staged/.gitleaksignore | 1 + testdata/repos/staged/README.md | 2 + testdata/repos/staged/api/api.go | 10 +++ testdata/repos/staged/dotGit/COMMIT_EDITMSG | 1 + testdata/repos/staged/dotGit/FETCH_HEAD | 1 + testdata/repos/staged/dotGit/HEAD | 1 + testdata/repos/staged/dotGit/ORIG_HEAD | 1 + testdata/repos/staged/dotGit/config | 13 +++ testdata/repos/staged/dotGit/description | 1 + testdata/repos/staged/dotGit/index | Bin 0 -> 359 bytes testdata/repos/staged/dotGit/info/exclude | 6 ++ testdata/repos/staged/dotGit/logs/HEAD | 14 +++ .../staged/dotGit/logs/refs/heads/api-pkg | 1 + .../repos/staged/dotGit/logs/refs/heads/foo | 3 + .../repos/staged/dotGit/logs/refs/heads/main | 3 + .../dotGit/logs/refs/heads/remove-secrets | 3 + .../dotGit/logs/refs/remotes/origin/HEAD | 1 + .../dotGit/logs/refs/remotes/origin/api-pkg | 1 + .../dotGit/logs/refs/remotes/origin/foo | 1 + .../dotGit/logs/refs/remotes/origin/main | 1 + .../02/d85657604c34e7b7fbb324a0c6c8b13c2c3760 | 1 + .../15/2888a42422b2ff5868b8d003d626120a9cb738 | Bin 0 -> 86 bytes .../2e/1db472eeba53f06c4026ae4566ea022e36598e | Bin 0 -> 618 bytes .../46/18d7e4512b6b0b1dab85cf846d9f43474ec8be | Bin 0 -> 44 bytes .../49/1504d5a31946ce75e22554cc34203d8e5ff3ca | Bin 0 -> 175 bytes .../5c/547e4215d9594c3935bdfefdf4f500016a4112 | Bin 0 -> 51 bytes .../65/83d6db4a57bbeda62d50fc91649036d499418d | Bin 0 -> 116 bytes .../66/bc70d0c0bfbb6468b3f90c3f1e9f2ddba02b43 | Bin 0 -> 155 bytes .../78/9ba677976d5db481de55c799d67acbf8e3f16a | Bin 0 -> 51 bytes .../90/6335481df9a4b48906c90318b4fac76b67fe73 | 3 + .../9a/932e37eaa9fb64b09e47e5e859c9b2c8cb47ad | Bin 0 -> 196 bytes .../a1/22b33c6bad3ee54724f52f2caad385ab1982ab | Bin 0 -> 163 bytes .../a5/caae6d742e49a33982f1fdc608ce861ea59be5 | Bin 0 -> 134 bytes .../a9/aa0c942dcef669a94f207a77426106b25efd1a | Bin 0 -> 143 bytes .../b1/6d768dd595a59f947abe087901183d219d7e54 | Bin 0 -> 182 bytes .../bc/f47ef84f29bb7ed6e653d61fccd30d0ecce886 | Bin 0 -> 116 bytes .../bf/3f24164d7256b4021575cbdb2f97b98e6f057e | 2 + .../d8/32479114dc6be7207edc7c37ce91dd11b93161 | Bin 0 -> 80 bytes .../da/2622b4d97e32c5801511244b809144b6b3ea78 | Bin 0 -> 51 bytes .../e5/c0849a65c586eab87dcfc31fec74f0fd7c62cb | Bin 0 -> 143 bytes .../f1/b58b97808f8e744f6a23c693859df5b5968901 | Bin 0 -> 176 bytes ...dc2976b84768d0829c75cc8d8fc4d849be62cd.idx | Bin 0 -> 1324 bytes ...c2976b84768d0829c75cc8d8fc4d849be62cd.pack | Bin 0 -> 2116 bytes testdata/repos/staged/dotGit/packed-refs | 2 + .../repos/staged/dotGit/refs/heads/api-pkg | 1 + testdata/repos/staged/dotGit/refs/heads/foo | 1 + testdata/repos/staged/dotGit/refs/heads/main | 1 + .../staged/dotGit/refs/heads/remove-secrets | 1 + .../staged/dotGit/refs/remotes/origin/HEAD | 1 + .../staged/dotGit/refs/remotes/origin/api-pkg | 1 + .../staged/dotGit/refs/remotes/origin/foo | 1 + .../staged/dotGit/refs/remotes/origin/main | 1 + testdata/repos/staged/main.go | 27 ++++++ 55 files changed, 195 insertions(+), 1 deletion(-) create mode 100644 testdata/repos/staged/.gitleaksignore create mode 100644 testdata/repos/staged/README.md create mode 100644 testdata/repos/staged/api/api.go create mode 100644 testdata/repos/staged/dotGit/COMMIT_EDITMSG create mode 100644 testdata/repos/staged/dotGit/FETCH_HEAD create mode 100644 testdata/repos/staged/dotGit/HEAD create mode 100644 testdata/repos/staged/dotGit/ORIG_HEAD create mode 100644 testdata/repos/staged/dotGit/config create mode 100644 testdata/repos/staged/dotGit/description create mode 100644 testdata/repos/staged/dotGit/index create mode 100644 testdata/repos/staged/dotGit/info/exclude create mode 100644 testdata/repos/staged/dotGit/logs/HEAD create mode 100644 testdata/repos/staged/dotGit/logs/refs/heads/api-pkg create mode 100644 testdata/repos/staged/dotGit/logs/refs/heads/foo create mode 100644 testdata/repos/staged/dotGit/logs/refs/heads/main create mode 100644 testdata/repos/staged/dotGit/logs/refs/heads/remove-secrets create mode 100644 testdata/repos/staged/dotGit/logs/refs/remotes/origin/HEAD create mode 100644 testdata/repos/staged/dotGit/logs/refs/remotes/origin/api-pkg create mode 100644 testdata/repos/staged/dotGit/logs/refs/remotes/origin/foo create mode 100644 testdata/repos/staged/dotGit/logs/refs/remotes/origin/main create mode 100644 testdata/repos/staged/dotGit/objects/02/d85657604c34e7b7fbb324a0c6c8b13c2c3760 create mode 100644 testdata/repos/staged/dotGit/objects/15/2888a42422b2ff5868b8d003d626120a9cb738 create mode 100644 testdata/repos/staged/dotGit/objects/2e/1db472eeba53f06c4026ae4566ea022e36598e create mode 100644 testdata/repos/staged/dotGit/objects/46/18d7e4512b6b0b1dab85cf846d9f43474ec8be create mode 100644 testdata/repos/staged/dotGit/objects/49/1504d5a31946ce75e22554cc34203d8e5ff3ca create mode 100644 testdata/repos/staged/dotGit/objects/5c/547e4215d9594c3935bdfefdf4f500016a4112 create mode 100644 testdata/repos/staged/dotGit/objects/65/83d6db4a57bbeda62d50fc91649036d499418d create mode 100644 testdata/repos/staged/dotGit/objects/66/bc70d0c0bfbb6468b3f90c3f1e9f2ddba02b43 create mode 100644 testdata/repos/staged/dotGit/objects/78/9ba677976d5db481de55c799d67acbf8e3f16a create mode 100644 testdata/repos/staged/dotGit/objects/90/6335481df9a4b48906c90318b4fac76b67fe73 create mode 100644 testdata/repos/staged/dotGit/objects/9a/932e37eaa9fb64b09e47e5e859c9b2c8cb47ad create mode 100644 testdata/repos/staged/dotGit/objects/a1/22b33c6bad3ee54724f52f2caad385ab1982ab create mode 100644 testdata/repos/staged/dotGit/objects/a5/caae6d742e49a33982f1fdc608ce861ea59be5 create mode 100644 testdata/repos/staged/dotGit/objects/a9/aa0c942dcef669a94f207a77426106b25efd1a create mode 100644 testdata/repos/staged/dotGit/objects/b1/6d768dd595a59f947abe087901183d219d7e54 create mode 100644 testdata/repos/staged/dotGit/objects/bc/f47ef84f29bb7ed6e653d61fccd30d0ecce886 create mode 100644 testdata/repos/staged/dotGit/objects/bf/3f24164d7256b4021575cbdb2f97b98e6f057e create mode 100644 testdata/repos/staged/dotGit/objects/d8/32479114dc6be7207edc7c37ce91dd11b93161 create mode 100644 testdata/repos/staged/dotGit/objects/da/2622b4d97e32c5801511244b809144b6b3ea78 create mode 100644 testdata/repos/staged/dotGit/objects/e5/c0849a65c586eab87dcfc31fec74f0fd7c62cb create mode 100644 testdata/repos/staged/dotGit/objects/f1/b58b97808f8e744f6a23c693859df5b5968901 create mode 100644 testdata/repos/staged/dotGit/objects/pack/pack-2cdc2976b84768d0829c75cc8d8fc4d849be62cd.idx create mode 100644 testdata/repos/staged/dotGit/objects/pack/pack-2cdc2976b84768d0829c75cc8d8fc4d849be62cd.pack create mode 100644 testdata/repos/staged/dotGit/packed-refs create mode 100644 testdata/repos/staged/dotGit/refs/heads/api-pkg create mode 100644 testdata/repos/staged/dotGit/refs/heads/foo create mode 100644 testdata/repos/staged/dotGit/refs/heads/main create mode 100644 testdata/repos/staged/dotGit/refs/heads/remove-secrets create mode 100644 testdata/repos/staged/dotGit/refs/remotes/origin/HEAD create mode 100644 testdata/repos/staged/dotGit/refs/remotes/origin/api-pkg create mode 100644 testdata/repos/staged/dotGit/refs/remotes/origin/foo create mode 100644 testdata/repos/staged/dotGit/refs/remotes/origin/main create mode 100644 testdata/repos/staged/main.go diff --git a/cmd/protect.go b/cmd/protect.go index 36007fa05..da2670960 100644 --- a/cmd/protect.go +++ b/cmd/protect.go @@ -66,11 +66,16 @@ func runProtect(cmd *cobra.Command, args []string) { if detector.Redact, err = cmd.Flags().GetBool("redact"); err != nil { log.Fatal().Err(err).Msg("") } - if detector.MaxTargetMegaBytes, err = cmd.Flags().GetInt("max-target-megabytes"); err != nil { log.Fatal().Err(err).Msg("") } + if fileExists(filepath.Join(source, ".gitleaksignore")) { + if err = detector.AddGitleaksIgnore(filepath.Join(source, ".gitleaksignore")); err != nil { + log.Fatal().Err(err).Msg("could not call AddGitleaksIgnore") + } + } + // get log options for git scan logOpts, err := cmd.Flags().GetString("log-opts") if err != nil { diff --git a/detect/detect_test.go b/detect/detect_test.go index 8c76f2ce3..f6f954585 100644 --- a/detect/detect_test.go +++ b/detect/detect_test.go @@ -485,6 +485,87 @@ func TestFromGit(t *testing.T) { assert.ElementsMatch(t, tt.expectedFindings, findings) } } +func TestFromGitStaged(t *testing.T) { + tests := []struct { + cfgName string + source string + logOpts string + expectedFindings []report.Finding + }{ + { + source: filepath.Join(repoBasePath, "staged"), + cfgName: "simple", + expectedFindings: []report.Finding{ + { + Description: "AWS Access Key", + StartLine: 7, + EndLine: 7, + StartColumn: 18, + EndColumn: 37, + Line: "\n\taws_token2 := \"AKIALALEMEL33243OLIA\" // this one is not", + Match: "AKIALALEMEL33243OLIA", + Secret: "AKIALALEMEL33243OLIA", + File: "api/api.go", + SymlinkFile: "", + Commit: "", + Entropy: 3.0841837, + Author: "", + Email: "", + Date: "0001-01-01T00:00:00Z", + Message: "", + Tags: []string{ + "key", + "AWS", + }, + RuleID: "aws-access-key", + Fingerprint: "api/api.go:aws-access-key:7", + }, + }, + }, + } + + err := moveDotGit("dotGit", ".git") + if err != nil { + t.Fatal(err) + } + defer func() { + if err := moveDotGit(".git", "dotGit"); err != nil { + t.Error(err) + } + }() + + for _, tt := range tests { + + viper.AddConfigPath(configPath) + viper.SetConfigName("simple") + viper.SetConfigType("toml") + err = viper.ReadInConfig() + if err != nil { + t.Error(err) + } + + var vc config.ViperConfig + err = viper.Unmarshal(&vc) + if err != nil { + t.Error(err) + } + cfg, err := vc.Translate() + if err != nil { + t.Error(err) + } + detector := NewDetector(cfg) + detector.AddGitleaksIgnore(filepath.Join(tt.source, ".gitleaksignore")) + findings, err := detector.DetectGit(tt.source, tt.logOpts, ProtectStagedType) + if err != nil { + t.Error(err) + } + + for _, f := range findings { + f.Match = "" // remove lines cause copying and pasting them has some wack formatting + } + assert.ElementsMatch(t, tt.expectedFindings, findings) + } +} // TestFromFiles tests the FromFiles function func TestFromFiles(t *testing.T) { diff --git a/testdata/repos/staged/.gitleaksignore b/testdata/repos/staged/.gitleaksignore new file mode 100644 index 000000000..770453ca4 --- /dev/null +++ b/testdata/repos/staged/.gitleaksignore @@ -0,0 +1 @@ +api/api.go:aws-access-key:6 \ No newline at end of file diff --git a/testdata/repos/staged/README.md b/testdata/repos/staged/README.md new file mode 100644 index 000000000..5cc9baf4d --- /dev/null +++ b/testdata/repos/staged/README.md @@ -0,0 +1,2 @@ +# test +This is a repo used for testing gitleaks diff --git a/testdata/repos/staged/api/api.go b/testdata/repos/staged/api/api.go new file mode 100644 index 000000000..b16d768dd --- /dev/null +++ b/testdata/repos/staged/api/api.go @@ -0,0 +1,10 @@ +package api + +import "fmt" + +func PrintHello() { + aws_token := "AKIALALEMEL33243OLIA" // fingerprint of that secret is added to .gitleaksignore + aws_token2 := "AKIALALEMEL33243OLIA" // this one is not + fmt.Println(aws_token) + fmt.Println(aws_token2) +} diff --git a/testdata/repos/staged/dotGit/COMMIT_EDITMSG b/testdata/repos/staged/dotGit/COMMIT_EDITMSG new file mode 100644 index 000000000..b83ad5393 --- /dev/null +++ b/testdata/repos/staged/dotGit/COMMIT_EDITMSG @@ -0,0 +1 @@ +add .gitleaksignore file diff --git a/testdata/repos/staged/dotGit/FETCH_HEAD b/testdata/repos/staged/dotGit/FETCH_HEAD new file mode 100644 index 000000000..66c1c77ce --- /dev/null +++ b/testdata/repos/staged/dotGit/FETCH_HEAD @@ -0,0 +1 @@ +2e1db472eeba53f06c4026ae4566ea022e36598e branch 'main' of github.com:gitleaks/test diff --git a/testdata/repos/staged/dotGit/HEAD b/testdata/repos/staged/dotGit/HEAD new file mode 100644 index 000000000..b870d8262 --- /dev/null +++ b/testdata/repos/staged/dotGit/HEAD @@ -0,0 +1 @@ +ref: refs/heads/main diff --git a/testdata/repos/staged/dotGit/ORIG_HEAD b/testdata/repos/staged/dotGit/ORIG_HEAD new file mode 100644 index 000000000..96321ccd4 --- /dev/null +++ b/testdata/repos/staged/dotGit/ORIG_HEAD @@ -0,0 +1 @@ +1b6da43b82b22e4eaa10bcf8ee591e91abbfc587 diff --git a/testdata/repos/staged/dotGit/config b/testdata/repos/staged/dotGit/config new file mode 100644 index 000000000..374df60b1 --- /dev/null +++ b/testdata/repos/staged/dotGit/config @@ -0,0 +1,13 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true + ignorecase = true + precomposeunicode = true +[remote "origin"] + url = git@github.com:gitleaks/test.git + fetch = +refs/heads/*:refs/remotes/origin/* +[branch "main"] + remote = origin + merge = refs/heads/main diff --git a/testdata/repos/staged/dotGit/description b/testdata/repos/staged/dotGit/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/testdata/repos/staged/dotGit/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/testdata/repos/staged/dotGit/index b/testdata/repos/staged/dotGit/index new file mode 100644 index 0000000000000000000000000000000000000000..42a3c4433f4d1e2ed0e9b4c42e0ca9a3c8fd5ecb GIT binary patch literal 359 zcmZ?q402{*U|<4bmK1T-AI9xbd@!1kfkB8-(e4EUL*o(#2F9;IH6lPP=O%IeNuYK% zx9sZH^DVjao!$LT>|@~9OV2FHNlnZy&P>nCFG>X}Oc7V&Q<-|u8B9-U*#I%m@EMwU z1~DgheYwg1mf_s$&=bx)8u#rS)3-8k2Dv)A_`2%lrU1>+n5M#XWgd)%nuG4H-y3tw zdaq7hI)6&lK8{L830uXvbs-E~i3OSZK&+RZ4|Eb3fZem~pE{Ucx>Olz-b++>F-p&x ztY`je 1635896329 -0500 clone: from github.com:gitleaks/test.git +1b6da43b82b22e4eaa10bcf8ee591e91abbfc587 1b6da43b82b22e4eaa10bcf8ee591e91abbfc587 Zach Rice 1635896362 -0500 checkout: moving from main to remove-secrets +1b6da43b82b22e4eaa10bcf8ee591e91abbfc587 906335481df9a4b48906c90318b4fac76b67fe73 Zach Rice 1635896426 -0500 commit: load token via env var +906335481df9a4b48906c90318b4fac76b67fe73 a122b33c6bad3ee54724f52f2caad385ab1982ab Zach Rice 1635896518 -0500 commit: add api package +a122b33c6bad3ee54724f52f2caad385ab1982ab a122b33c6bad3ee54724f52f2caad385ab1982ab Zach Rice 1635896543 -0500 checkout: moving from remove-secrets to api-pkg +a122b33c6bad3ee54724f52f2caad385ab1982ab 1b6da43b82b22e4eaa10bcf8ee591e91abbfc587 Zach Rice 1635896644 -0500 checkout: moving from api-pkg to main +1b6da43b82b22e4eaa10bcf8ee591e91abbfc587 2e1db472eeba53f06c4026ae4566ea022e36598e Zach Rice 1635896648 -0500 pull origin main: Fast-forward +2e1db472eeba53f06c4026ae4566ea022e36598e 2e1db472eeba53f06c4026ae4566ea022e36598e Zach Rice 1635896716 -0500 checkout: moving from main to foo +2e1db472eeba53f06c4026ae4566ea022e36598e 491504d5a31946ce75e22554cc34203d8e5ff3ca Zach Rice 1635896886 -0500 commit: adding foo package with secret +491504d5a31946ce75e22554cc34203d8e5ff3ca f1b58b97808f8e744f6a23c693859df5b5968901 Zach Rice 1635896931 -0500 commit: removing secret from foo package +f1b58b97808f8e744f6a23c693859df5b5968901 2e1db472eeba53f06c4026ae4566ea022e36598e Zach Rice 1635897009 -0500 checkout: moving from foo to main +2e1db472eeba53f06c4026ae4566ea022e36598e f1b58b97808f8e744f6a23c693859df5b5968901 Zach Rice 1635897062 -0500 checkout: moving from main to foo +f1b58b97808f8e744f6a23c693859df5b5968901 2e1db472eeba53f06c4026ae4566ea022e36598e Zach Rice 1635897508 -0500 checkout: moving from foo to main +2e1db472eeba53f06c4026ae4566ea022e36598e bf3f24164d7256b4021575cbdb2f97b98e6f057e Rafael Figueiredo 1679239434 -0300 commit: add .gitleaksignore file diff --git a/testdata/repos/staged/dotGit/logs/refs/heads/api-pkg b/testdata/repos/staged/dotGit/logs/refs/heads/api-pkg new file mode 100644 index 000000000..18e1cff1a --- /dev/null +++ b/testdata/repos/staged/dotGit/logs/refs/heads/api-pkg @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 a122b33c6bad3ee54724f52f2caad385ab1982ab Zach Rice 1635896543 -0500 branch: Created from HEAD diff --git a/testdata/repos/staged/dotGit/logs/refs/heads/foo b/testdata/repos/staged/dotGit/logs/refs/heads/foo new file mode 100644 index 000000000..0588ad530 --- /dev/null +++ b/testdata/repos/staged/dotGit/logs/refs/heads/foo @@ -0,0 +1,3 @@ +0000000000000000000000000000000000000000 2e1db472eeba53f06c4026ae4566ea022e36598e Zach Rice 1635896716 -0500 branch: Created from HEAD +2e1db472eeba53f06c4026ae4566ea022e36598e 491504d5a31946ce75e22554cc34203d8e5ff3ca Zach Rice 1635896886 -0500 commit: adding foo package with secret +491504d5a31946ce75e22554cc34203d8e5ff3ca f1b58b97808f8e744f6a23c693859df5b5968901 Zach Rice 1635896931 -0500 commit: removing secret from foo package diff --git a/testdata/repos/staged/dotGit/logs/refs/heads/main b/testdata/repos/staged/dotGit/logs/refs/heads/main new file mode 100644 index 000000000..c4bd6cb68 --- /dev/null +++ b/testdata/repos/staged/dotGit/logs/refs/heads/main @@ -0,0 +1,3 @@ +0000000000000000000000000000000000000000 1b6da43b82b22e4eaa10bcf8ee591e91abbfc587 Zach Rice 1635896329 -0500 clone: from github.com:gitleaks/test.git +1b6da43b82b22e4eaa10bcf8ee591e91abbfc587 2e1db472eeba53f06c4026ae4566ea022e36598e Zach Rice 1635896648 -0500 pull origin main: Fast-forward +2e1db472eeba53f06c4026ae4566ea022e36598e bf3f24164d7256b4021575cbdb2f97b98e6f057e Rafael Figueiredo 1679239434 -0300 commit: add .gitleaksignore file diff --git a/testdata/repos/staged/dotGit/logs/refs/heads/remove-secrets b/testdata/repos/staged/dotGit/logs/refs/heads/remove-secrets new file mode 100644 index 000000000..58344a340 --- /dev/null +++ b/testdata/repos/staged/dotGit/logs/refs/heads/remove-secrets @@ -0,0 +1,3 @@ +0000000000000000000000000000000000000000 1b6da43b82b22e4eaa10bcf8ee591e91abbfc587 Zach Rice 1635896362 -0500 branch: Created from HEAD +1b6da43b82b22e4eaa10bcf8ee591e91abbfc587 906335481df9a4b48906c90318b4fac76b67fe73 Zach Rice 1635896426 -0500 commit: load token via env var +906335481df9a4b48906c90318b4fac76b67fe73 a122b33c6bad3ee54724f52f2caad385ab1982ab Zach Rice 1635896518 -0500 commit: add api package diff --git a/testdata/repos/staged/dotGit/logs/refs/remotes/origin/HEAD b/testdata/repos/staged/dotGit/logs/refs/remotes/origin/HEAD new file mode 100644 index 000000000..a2076e59a --- /dev/null +++ b/testdata/repos/staged/dotGit/logs/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 1b6da43b82b22e4eaa10bcf8ee591e91abbfc587 Zach Rice 1635896329 -0500 clone: from github.com:gitleaks/test.git diff --git a/testdata/repos/staged/dotGit/logs/refs/remotes/origin/api-pkg b/testdata/repos/staged/dotGit/logs/refs/remotes/origin/api-pkg new file mode 100644 index 000000000..9c8e059cf --- /dev/null +++ b/testdata/repos/staged/dotGit/logs/refs/remotes/origin/api-pkg @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 a122b33c6bad3ee54724f52f2caad385ab1982ab Zach Rice 1635896552 -0500 update by push diff --git a/testdata/repos/staged/dotGit/logs/refs/remotes/origin/foo b/testdata/repos/staged/dotGit/logs/refs/remotes/origin/foo new file mode 100644 index 000000000..f6aed264f --- /dev/null +++ b/testdata/repos/staged/dotGit/logs/refs/remotes/origin/foo @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 f1b58b97808f8e744f6a23c693859df5b5968901 Zach Rice 1635896935 -0500 update by push diff --git a/testdata/repos/staged/dotGit/logs/refs/remotes/origin/main b/testdata/repos/staged/dotGit/logs/refs/remotes/origin/main new file mode 100644 index 000000000..530a7894d --- /dev/null +++ b/testdata/repos/staged/dotGit/logs/refs/remotes/origin/main @@ -0,0 +1 @@ +1b6da43b82b22e4eaa10bcf8ee591e91abbfc587 2e1db472eeba53f06c4026ae4566ea022e36598e Zach Rice 1635896648 -0500 pull origin main: fast-forward diff --git a/testdata/repos/staged/dotGit/objects/02/d85657604c34e7b7fbb324a0c6c8b13c2c3760 b/testdata/repos/staged/dotGit/objects/02/d85657604c34e7b7fbb324a0c6c8b13c2c3760 new file mode 100644 index 000000000..dab89999a --- /dev/null +++ b/testdata/repos/staged/dotGit/objects/02/d85657604c34e7b7fbb324a0c6c8b13c2c3760 @@ -0,0 +1 @@ +xU1 0`ܯ8nJ.:*(8\ɕ$ w3 Nox{$6f1~wF'0YbF TBpND|*]uCST kL>a#(Jm(sԴ]=>03 \ No newline at end of file diff --git a/testdata/repos/staged/dotGit/objects/15/2888a42422b2ff5868b8d003d626120a9cb738 b/testdata/repos/staged/dotGit/objects/15/2888a42422b2ff5868b8d003d626120a9cb738 new file mode 100644 index 0000000000000000000000000000000000000000..f9ada07217b81e2055ac789cce7a4e74b3e98571 GIT binary patch literal 86 zcmV-c0IC0Y0V^p=O;s>AVlXr?Ff%bx2y%6F@paY9O<{;Rx$DbK{Gumc8zsg>LAvJ2Q?U=6|e)0ejD zt)0tgetI*~(;L#%b=d>mgkO42DZqp&I%S5!poy_gGmUDhoM{pxB$LHVq=Znz(1aFo zdhLOPwG1gTHXw$ODik3}oNpMEs-{Fu31Q5LYUqFUNP-Z{GSM)~K=|mDM-W)Zc-m$*N&$nrMP2Q58jD zrn9S_a^RNz+knCIwc)g_rq{geivj;}e|3-se&PcNL%e zQ;;b4v@3VTLW-;)cgwUii_$DRy-9v ztpA;u;8UJc&<<4vIPC^{>%mtEFy7Q){)mdA%Wa9;@~OS#f?#DCm8U`Q;;)CXd{^n9zt@?zb@ z+g3V|4{yDhfkYA1=qagX<|xr;!bzsd6A#D>1O;7fFcTTz3L-*%#1k5+r#H!0s2t=lIIJcc>)JTtswKy;@)7rXr{ dc9K%r?~rSSL-ZkcgP+n@c$zlr?hoKjPX=)8R5Snp literal 0 HcmV?d00001 diff --git a/testdata/repos/staged/dotGit/objects/5c/547e4215d9594c3935bdfefdf4f500016a4112 b/testdata/repos/staged/dotGit/objects/5c/547e4215d9594c3935bdfefdf4f500016a4112 new file mode 100644 index 0000000000000000000000000000000000000000..5bddb82e2d848a5f668c70a9b3a5d8887c4cfc67 GIT binary patch literal 51 zcmV-30L=e*0V^p=O;s>9VK6i>Ff%bxNG!40ZYosPf{>6G+-!5OwLYBPgO`P$mHV6%q_?-Dp62M%Pmpj;z}#cOI8Rd z%FHYANX^N~*U(g`=Hg5&FODzC&rZ!#u(DN9a`g6e^l|iY^>y_zHa0Rb_V@90RN~?U W>emBn%*oS$YtZDX7F=a3`FfcPQQP4}zEXhet%r4GM&&w}LWpI-m=4`OfZsC-y;=2Dv)A_`2%lrZB{u-1X%q|67K0t3yvX^Jv_+b4=fAVgLjRi3OPq zF(GwMqBkRbEKT?R`}^f917nt>5Y&j=#LPUs^n8X{ll9DBt^A#`VV?Wb7m+77ojC2j J767+rJXdN*O&|aO literal 0 HcmV?d00001 diff --git a/testdata/repos/staged/dotGit/objects/78/9ba677976d5db481de55c799d67acbf8e3f16a b/testdata/repos/staged/dotGit/objects/78/9ba677976d5db481de55c799d67acbf8e3f16a new file mode 100644 index 0000000000000000000000000000000000000000..93acde0f58e563f655dbebe3a98dbf7b2cd06937 GIT binary patch literal 51 zcmV-30L=e*0V^p=O;s>9VK6i>Ff%bxNXyUHOV4Lux)Bzh;A8T9`|r&v3yz)GXrp7E J0016I4}|e<6uAHZ literal 0 HcmV?d00001 diff --git a/testdata/repos/staged/dotGit/objects/90/6335481df9a4b48906c90318b4fac76b67fe73 b/testdata/repos/staged/dotGit/objects/90/6335481df9a4b48906c90318b4fac76b67fe73 new file mode 100644 index 000000000..ce4a269d3 --- /dev/null +++ b/testdata/repos/staged/dotGit/objects/90/6335481df9a4b48906c90318b4fac76b67fe73 @@ -0,0 +1,3 @@ +xM +0F]s%t +"I2E۔ >x_2w@;z㑈ءCX@6 5)M&F:l'FTHďFF1iPSm4cNo;ݷV{]ߗT`=aZw d}fuKK \ No newline at end of file diff --git a/testdata/repos/staged/dotGit/objects/9a/932e37eaa9fb64b09e47e5e859c9b2c8cb47ad b/testdata/repos/staged/dotGit/objects/9a/932e37eaa9fb64b09e47e5e859c9b2c8cb47ad new file mode 100644 index 0000000000000000000000000000000000000000..5e51e39d45702fbb232d53354c28fdca96718e6a GIT binary patch literal 196 zcmV;#06YJ90bPzU3&JoEggrOQLKvy9UR0#P(i^_uI*Jq)1;)a4&r||DLB;W z;C}EY9EH@< zNm5?*h56Y^?UatmS4O8uu|%JFb(vx|wF3N!l{cJy^3FMD*&freTen98Evpv-5E*wztdudOGZmB9!Yu1$CX`zyIq5KJWzunN+wPUSfIx literal 0 HcmV?d00001 diff --git a/testdata/repos/staged/dotGit/objects/a1/22b33c6bad3ee54724f52f2caad385ab1982ab b/testdata/repos/staged/dotGit/objects/a1/22b33c6bad3ee54724f52f2caad385ab1982ab new file mode 100644 index 0000000000000000000000000000000000000000..fbcf357cc571a102e357b16d95a3538941f33de3 GIT binary patch literal 163 zcmV;U09^lg0iBLP4#FT106p`H{eT7vERY!E8$5bjmPH$FX$W3?y?ukHNhX( zV6yr!x(H;hE=Y~8PATUg1qHn=Xex8Dx@cjR7*TE1WgU<-TI*djr6zLO#a(dH*2L^8 zalnkBO0bGPXKbJNk9&ZM1cv`F-NHT)?39F`+jRj@oOjcDpYQ`72gb R3eYygM*O0Os2|U*Nw*#3PL%)v literal 0 HcmV?d00001 diff --git a/testdata/repos/staged/dotGit/objects/a5/caae6d742e49a33982f1fdc608ce861ea59be5 b/testdata/repos/staged/dotGit/objects/a5/caae6d742e49a33982f1fdc608ce861ea59be5 new file mode 100644 index 0000000000000000000000000000000000000000..8be258a32c78adf07fdfe065081c2ef755049b8d GIT binary patch literal 134 zcmV;10D1p-0ac8#3c@fH0A2IG;_;?tv1nWr95PfWjp!dpS`sO3@=BB9ApX0Z1lQy4 z+L2q_spDp{-C&;%Ju^TbCZ02r519b`5<9#w7ZTqfR<^y*eavGlXthZKh_b}wTu7L# ocOdL5Ju(k2;^~Z}n_3%fs%vGG+8@--)SCWBzd*tVz6gvg!CC@8Z~y=R literal 0 HcmV?d00001 diff --git a/testdata/repos/staged/dotGit/objects/a9/aa0c942dcef669a94f207a77426106b25efd1a b/testdata/repos/staged/dotGit/objects/a9/aa0c942dcef669a94f207a77426106b25efd1a new file mode 100644 index 0000000000000000000000000000000000000000..9221b3c0ad1fcb47f3445b805507bb6d16a28197 GIT binary patch literal 143 zcmV;A0C4|!0V^p=O;s>7HexU|FfcPQQ3!H%bn$i7%S~a3Il1f0P5!qG=T?WFaOTmt zZ|9i4)x-b@6cP(E8Dc`}oJ4O%`dFIo{rC6FR|du`MDU~-W38KgBEui|BvcRe1i2bg{QR>~g8%>k literal 0 HcmV?d00001 diff --git a/testdata/repos/staged/dotGit/objects/bc/f47ef84f29bb7ed6e653d61fccd30d0ecce886 b/testdata/repos/staged/dotGit/objects/bc/f47ef84f29bb7ed6e653d61fccd30d0ecce886 new file mode 100644 index 0000000000000000000000000000000000000000..ec618b7a930fa1ad86255b0c385d1d9e439ff27d GIT binary patch literal 116 zcmV-)0E_>40V^p=O;s>7Fk&z?FfcPQQ3!H%bn$i7%S~a3Il1f0P5!qG=T?WFaOTmt zZ|9i4)x-b@6cP(E8Dc`}oJ4O%`dFIo{rC6FR|du`MӷF_uQ;rS/jozH[&Yu;OM;;fhtXؠ?Ϻ[_]U \ No newline at end of file diff --git a/testdata/repos/staged/dotGit/objects/d8/32479114dc6be7207edc7c37ce91dd11b93161 b/testdata/repos/staged/dotGit/objects/d8/32479114dc6be7207edc7c37ce91dd11b93161 new file mode 100644 index 0000000000000000000000000000000000000000..0bd9a371a3ad63ecb59017199a81859c334ad129 GIT binary patch literal 80 zcmV-W0I&ae0ZYosPf{>9WGF~X&Q45ERY)wz#Y>~ literal 0 HcmV?d00001 diff --git a/testdata/repos/staged/dotGit/objects/e5/c0849a65c586eab87dcfc31fec74f0fd7c62cb b/testdata/repos/staged/dotGit/objects/e5/c0849a65c586eab87dcfc31fec74f0fd7c62cb new file mode 100644 index 0000000000000000000000000000000000000000..53b83ef007a757e589e3cf16407ff49717397595 GIT binary patch literal 143 zcmV;A0C4|!0V^p=O;s>7HexU|FfcPQQ3!H%bn$i7%S~a3Il1f0P5!qG=T?WFaOTmt zZ|9i4)x-b@6cP(E8Dc`}oJ4O%`dFIo{rC6FR|du`M^uWjW>vuaQEcJLJ z>L?w@o3MG_#P_-@tE`tBRQ_N~E`9EzdVKecqb%|7rS!P8eom0mOD@ltuB>-{mwfbU z*H`zpt>JN+JJIsc*E~ykv8($JK7QPL1QK*?0YJa=0E;stV3xZI#0!8$LMSlF&IaPw vI(Ib7cDQF;Xqr=crnmpd4bOc^XAerFx|G@YAb-QBa2mkt=K#Lt>myWQtA&0RcKbuip?!xQV?Zf zfK&@@521UF$9mfA_7^N3u zXRrTixpZ@3B(aO$zo#ccuc`2{8TEYKk1*gD_t0slafXGv#MH>j|!Qu&8<5X z=&9g@H9H5gM!4BzT|YqQL9(m^AIL6Ewnbinu{6W&8mTvgnJ;&2){vv)4R0Ktd{6!m zyDzcXEU)dgFL{#r_X&kvIJH!Fiq`~LZ^paf^^HDnmK174*!i3s;hP_OSAdyhrH?}L zHD>oRn+z5=+w_kYWoO>Cj0T-naJCDpM==;$p>~NcyC~Zi1;i?1%Y`P-U`FCb*x*0c zVshQm#C1NNY0^Q8hBYH~L86JHo)sN1LW?b)nOxKEDUceaddeJ*#Cfb$FD@k;fe1o# zeLvPql}d0G!#rY0P+%`g&4dh{W^IH+8Ncd`C%lS8Ji960spKsoX(#WPG9el0^89(% zthmmuy%N67Am{}wGC*8#8Lc3Pk4)c9RrzY8emU{zvB8bN_~9i8ckId8qc4J&F_V0t z4p!|~L!k2lrhD2@DL?yu+s#IG=<+Pobnt%9!xb&@Fo0^5&I$fJQkl_^!BJM{UC*J> zDUnA$`P7*(sr3-^{<5fV+roJ=$t&om7$x=uqhW)K@;xAI+lP=XWnJhQ@w5)4lEcuD zpr9E{OnZGJbe_Do8&t}KzgNQs)EwlEkpRA}lXk^w|6L>?s?q|Gu;8;wSZd-lSM{#Q_-=Kra`A&KRB1jvazbngfBjgn&`bJzAm6xn_l`)i@ zC$=@Pd*bvFwpy;t+e;!<%5R0@d7Zet#GF;fo~7=Hlc=Ph&vp!o6n)1|pNN$sT1Z;X zQc>y){CpRFa{UDYhe6&L8n?TOhz~i=EC`q!6(=61|HK}hkLcE(*k?|CwVT-A;g?UT z=s;5;+S3p#&8wavOx4Tng??U|C4|AlUdY3kO=r?4C=n+@PC%$Ew@9;2KbGKGEf37Q z%H4V%PxSS3<@(|D-+bwO7sDM0El&*ZN?i{*W@p&OYmiyY#A|QIHR%OQaDc{f^!^*T zSmn@5sDrc5Gw248+-sVLn##n)){%^_fxOWRgBen?4BXHolf^npn?%alXh}-1f|&rf zFQS2?+5P}l&wYhEFeL~sduu^rs7p-SxbmUC2zp!ajlf8ihBY|A7ynBNa(LH8G(YB? z2wUnCqj}ltPGxu%sg-*%*n%1uYQn1%*iwB67_6`BE`*N7uw%!l&et=Hx>l&pM;#&y-Ve*8=RbEwEfn>P z0V~xEboE_zOkec&aqL!eh`%a!Efe4!4;}89QhiSI0$xkVv^Mf#OFg{R?6oh=3J>&a zc>^k~(<{H+OGu})zMM^OJydKA4h_Ux#)aCu+zh&{3j*X=18Hq%v85ryB++|dpulFg zE4w;hnQT52%z8It@nLc1ROuEt+wD0V1MVSIi#{Kz=(|JOS=aKqgV*(=+X{V~8oJw$ z--c(zfxWZ_#ffPahGJ;>Rr$8hfgVaX&hN2STiMyg?wovvkw%&!6fvCVvWhsK(=gl+ zC^y`Gh&_x}G|Y4-7CK_achoE#nuNJKSB-Y$aketH_^h1r-_?Yc-pi}`e`FB{slQ|X z73zy0a0$tyMlpT>t<8 literal 0 HcmV?d00001 diff --git a/testdata/repos/staged/dotGit/packed-refs b/testdata/repos/staged/dotGit/packed-refs new file mode 100644 index 000000000..859b8c5a8 --- /dev/null +++ b/testdata/repos/staged/dotGit/packed-refs @@ -0,0 +1,2 @@ +# pack-refs with: peeled fully-peeled sorted +1b6da43b82b22e4eaa10bcf8ee591e91abbfc587 refs/remotes/origin/main diff --git a/testdata/repos/staged/dotGit/refs/heads/api-pkg b/testdata/repos/staged/dotGit/refs/heads/api-pkg new file mode 100644 index 000000000..31b6c7893 --- /dev/null +++ b/testdata/repos/staged/dotGit/refs/heads/api-pkg @@ -0,0 +1 @@ +a122b33c6bad3ee54724f52f2caad385ab1982ab diff --git a/testdata/repos/staged/dotGit/refs/heads/foo b/testdata/repos/staged/dotGit/refs/heads/foo new file mode 100644 index 000000000..57d584841 --- /dev/null +++ b/testdata/repos/staged/dotGit/refs/heads/foo @@ -0,0 +1 @@ +f1b58b97808f8e744f6a23c693859df5b5968901 diff --git a/testdata/repos/staged/dotGit/refs/heads/main b/testdata/repos/staged/dotGit/refs/heads/main new file mode 100644 index 000000000..a06d4d30f --- /dev/null +++ b/testdata/repos/staged/dotGit/refs/heads/main @@ -0,0 +1 @@ +bf3f24164d7256b4021575cbdb2f97b98e6f057e diff --git a/testdata/repos/staged/dotGit/refs/heads/remove-secrets b/testdata/repos/staged/dotGit/refs/heads/remove-secrets new file mode 100644 index 000000000..31b6c7893 --- /dev/null +++ b/testdata/repos/staged/dotGit/refs/heads/remove-secrets @@ -0,0 +1 @@ +a122b33c6bad3ee54724f52f2caad385ab1982ab diff --git a/testdata/repos/staged/dotGit/refs/remotes/origin/HEAD b/testdata/repos/staged/dotGit/refs/remotes/origin/HEAD new file mode 100644 index 000000000..4b0a87595 --- /dev/null +++ b/testdata/repos/staged/dotGit/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +ref: refs/remotes/origin/main diff --git a/testdata/repos/staged/dotGit/refs/remotes/origin/api-pkg b/testdata/repos/staged/dotGit/refs/remotes/origin/api-pkg new file mode 100644 index 000000000..31b6c7893 --- /dev/null +++ b/testdata/repos/staged/dotGit/refs/remotes/origin/api-pkg @@ -0,0 +1 @@ +a122b33c6bad3ee54724f52f2caad385ab1982ab diff --git a/testdata/repos/staged/dotGit/refs/remotes/origin/foo b/testdata/repos/staged/dotGit/refs/remotes/origin/foo new file mode 100644 index 000000000..57d584841 --- /dev/null +++ b/testdata/repos/staged/dotGit/refs/remotes/origin/foo @@ -0,0 +1 @@ +f1b58b97808f8e744f6a23c693859df5b5968901 diff --git a/testdata/repos/staged/dotGit/refs/remotes/origin/main b/testdata/repos/staged/dotGit/refs/remotes/origin/main new file mode 100644 index 000000000..98f12e928 --- /dev/null +++ b/testdata/repos/staged/dotGit/refs/remotes/origin/main @@ -0,0 +1 @@ +2e1db472eeba53f06c4026ae4566ea022e36598e diff --git a/testdata/repos/staged/main.go b/testdata/repos/staged/main.go new file mode 100644 index 000000000..9a932e37e --- /dev/null +++ b/testdata/repos/staged/main.go @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "os" +) + +func main() { + + var a = "initial" + fmt.Println(a) + + var b, c int = 1, 2 + fmt.Println(b, c) + + var d = true + fmt.Println(d) + + var e int + fmt.Println(e) + + // load secret via env + awsToken := os.Getenv("AWS_TOKEN") + + f := "apple" + fmt.Println(f) +}