Skip to content

Find, verify, and analyze leaked credentials

2396 since commit stopped working (#2402)

ahrave8006f1beebc
diff --git a/pkg/gitparse/gitparse.go b/pkg/gitparse/gitparse.go
index da39be0f9..dbcf4604c 100644
--- a/pkg/gitparse/gitparse.go
+++ b/pkg/gitparse/gitparse.go
@@ -148,7 +148,9 @@ func (d *Diff) write(ctx context.Context, p []byte) error {
// finalize ensures proper closure of resources associated with the Diff.
// handle the final flush in the finalize method, in case there's data remaining in the buffer.
// This method should be called to release resources, especially when writing to a file.
-func (d *Diff) finalize() error { return d.contentWriter.CloseForWriting() }
+func (d *Diff) finalize() error {
+ return d.contentWriter.CloseForWriting()
+}
// Commit contains commit header info and diffs.
type Commit struct {
@@ -157,6 +159,8 @@ type Commit struct {
Date time.Time
Message strings.Builder
Size int // in bytes
+
+ hasDiffs bool
}
// Parser sets values used in GitParse.
@@ -393,11 +397,19 @@ func (c *Parser) FromReader(ctx context.Context, stdOut io.Reader, diffChan chan
}
diffChan <- currentDiff
currentCommit.Size += currentDiff.Len()
+ currentCommit.hasDiffs = true
}
// If there is a currentCommit, send it to the channel.
if currentCommit != nil {
totalLogSize += currentCommit.Size
+ if !currentCommit.hasDiffs {
+ // Initialize an empty Diff instance associated with the given commit.
+ // Since this diff represents "no changes", we only need to set the commit.
+ // This is required to ensure commits that have no diffs are still processed.
+ diffChan <- &Diff{Commit: currentCommit}
+ }
}
+
// Create a new currentDiff and currentCommit
currentCommit = &Commit{Message: strings.Builder{}}
currentDiff = diff(currentCommit)
@@ -432,10 +444,6 @@ func (c *Parser) FromReader(ctx context.Context, stdOut io.Reader, diffChan chan
case isDiffLine(isStaged, latestState, line):
latestState = DiffLine
- // This should never be nil, but check in case the stdin stream is messed up.
- if currentCommit == nil {
- currentCommit = &Commit{}
- }
if currentDiff.Len() > 0 || currentDiff.IsBinary {
if err := currentDiff.finalize(); err != nil {
ctx.Logger().Error(err,
@@ -447,6 +455,12 @@ func (c *Parser) FromReader(ctx context.Context, stdOut io.Reader, diffChan chan
)
}
diffChan <- currentDiff
+ currentCommit.hasDiffs = true
+ }
+
+ // This should never be nil, but check in case the stdin stream is messed up.
+ if currentCommit == nil {
+ currentCommit = &Commit{}
}
currentDiff = diff(currentCommit)
case isModeLine(latestState, line):
diff --git a/pkg/gitparse/gitparse_test.go b/pkg/gitparse/gitparse_test.go
index e7b93ca6d..df2cfbfd2 100644
--- a/pkg/gitparse/gitparse_test.go
+++ b/pkg/gitparse/gitparse_test.go
@@ -626,15 +626,25 @@ func (d1 *Diff) Equal(ctx context.Context, d2 *Diff) bool {
switch {
case d1.PathB != d2.PathB:
return false
+ case d1.Commit.Hash != d2.Commit.Hash:
+ return false
+ case d1.Commit.Author != d2.Commit.Author:
+ return false
+ case d1.Commit.Date != d2.Commit.Date:
+ return false
+ case d1.Commit.Message.String() != d2.Commit.Message.String():
+ return false
case d1.LineStart != d2.LineStart:
return false
case d1.IsBinary != d2.IsBinary:
return false
default:
- equal, err := isEqualContentString(d1.contentWriter, d2.contentWriter)
- if err != nil || !equal {
- ctx.Logger().Error(err, "failed to compare diff content")
- return false
+ if d1.contentWriter != nil && d2.contentWriter != nil {
+ equal, err := isEqualContentString(d1.contentWriter, d2.contentWriter)
+ if err != nil || !equal {
+ ctx.Logger().Error(err, "failed to compare diff content")
+ return false
+ }
}
}
return true
@@ -643,7 +653,7 @@ func (d1 *Diff) Equal(ctx context.Context, d2 *Diff) bool {
func TestCommitParsing(t *testing.T) {
expected := expectedDiffs()
- r := bytes.NewReader([]byte(diffLog))
+ r := bytes.NewReader([]byte(commitLog))
diffChan := make(chan *Diff)
parser := NewParser()
go func() {
@@ -657,46 +667,12 @@ func TestCommitParsing(t *testing.T) {
}
if !diff.Equal(context.Background(), expected[i]) {
- t.Errorf("Diff does not match.\nexpected: %+v\n%s\nactual : %+v\n%s", expected[i], expected[i].Commit.Message.String(), diff, diff.Commit.Message.String())
+ t.Errorf("Diff does not match.\nexpected: %+v\n%s\nactual : %+v\n%s", expected[i], expected[i].Commit.Hash, diff, diff.Commit.Hash)
}
i++
}
}
-func TestIndividualCommitParsing(t *testing.T) {
- // Arrange
- expected := expectedDiffs()
- commits := strings.Split(diffLog, "\ndiff --git")
- for index, commit := range commits {
- if !strings.HasPrefix(commit, "commit") {
- commits[index] = "commit " + commit
- }
- }
-
- // Act
- for i, commit := range commits {
- r := bytes.NewReader([]byte(commit))
- diffChan := make(chan *Diff)
- parser := NewParser()
- go func() {
- parser.FromReader(context.Background(), r, diffChan, false)
- }()
- j := 0
- for diff := range diffChan {
- if len(expected) <= i {
- t.Errorf("Missing expected case for commit: %+v", diff)
- break
- }
-
- // Assert
- if !diff.Equal(context.Background(), expected[i]) {
- t.Errorf("Diff does not match.\nexpected: %+v\n%s\nactual : %+v\n%s", expected[i], expected[j].Commit.Message.String(), diff, diff.Commit.Message.String())
- }
- j++
- }
- }
-}
-
func newBufferedFileWriterWithContent(content []byte) *bufferedfilewriter.BufferedFileWriter {
b := bufferedfilewriter.New()
_, err := b.Write(context.Background(), content) // Using Write method to add content
@@ -715,43 +691,85 @@ func newBufferWithContent(content []byte) *buffer {
func TestStagedDiffParsing(t *testing.T) {
expected := []*Diff{
{
- PathB: "aws",
- LineStart: 1,
+ PathB: "aws",
+ LineStart: 1,
+ Commit: &Commit{
+ Hash: "",
+ Author: "",
+ Date: newTime("0001-01-01 00:00:00 +0000 UTC"),
+ Message: strings.Builder{},
+ },
contentWriter: newBufferWithContent([]byte("[default]\naws_access_key_id = AKIAXYZDQCEN4B6JSJQI\naws_secret_access_key = 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\noutput = json\nregion = us-east-2\n")),
IsBinary: false,
},
{
- PathB: "aws2",
- LineStart: 1,
+ PathB: "aws2",
+ LineStart: 1,
+ Commit: &Commit{
+ Hash: "",
+ Author: "",
+ Date: newTime("0001-01-01 00:00:00 +0000 UTC"),
+ Message: strings.Builder{},
+ },
contentWriter: newBufferWithContent([]byte("\n\nthis is the secret: [Default]\nAccess key Id: AKIAILE3JG6KMS3HZGCA\nSecret Access Key: 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\n\nokay thank you bye\n")),
IsBinary: false,
},
{
- PathB: "core/runtime/src/main/java/io/quarkus/runtime/QuarkusApplication.java",
- LineStart: 3,
+ PathB: "core/runtime/src/main/java/io/quarkus/runtime/QuarkusApplication.java",
+ LineStart: 3,
+ Commit: &Commit{
+ Hash: "",
+ Author: "",
+ Date: newTime("0001-01-01 00:00:00 +0000 UTC"),
+ Message: strings.Builder{},
+ },
contentWriter: newBufferWithContent([]byte("/**\n * This is usually used for command mode applications with a startup logic. The logic is executed inside\n * {@link QuarkusApplication#run} method before the main application exits.\n */\n")),
IsBinary: false,
},
{
- PathB: "trufflehog_3.42.0_linux_arm64.tar.gz",
- IsBinary: true,
+ PathB: "trufflehog_3.42.0_linux_arm64.tar.gz",
+ IsBinary: true,
+ Commit: &Commit{
+ Hash: "",
+ Author: "",
+ Date: newTime("0001-01-01 00:00:00 +0000 UTC"),
+ Message: strings.Builder{},
+ },
contentWriter: newBufferWithContent(nil),
},
{
- PathB: "tzu",
- LineStart: 11,
+ PathB: "tzu",
+ LineStart: 11,
+ Commit: &Commit{
+ Hash: "",
+ Author: "",
+ Date: newTime("0001-01-01 00:00:00 +0000 UTC"),
+ Message: strings.Builder{},
+ },
contentWriter: newBufferWithContent([]byte("\n\n\n\nSource: https://www.gnu.org/software/diffutils/manual/diffutils.html#An-Example-of-Unified-Format\n")),
IsBinary: false,
},
{
- PathB: "lao",
- LineStart: 1,
+ PathB: "lao",
+ LineStart: 1,
+ Commit: &Commit{
+ Hash: "",
+ Author: "",
+ Date: newTime("0001-01-01 00:00:00 +0000 UTC"),
+ Message: strings.Builder{},
+ },
contentWriter: newBufferWithContent([]byte("The Way that can be told of is not the eternal Way;\nThe name that can be named is not the eternal name.\nThe Nameless is the origin of Heaven and Earth;\nThe Named is the mother of all things.\nTherefore let there always be non-being,\n so we may see their subtlety,\nAnd let there always be being,\n so we may see their outcome.\nThe two are the same,\nBut after they are produced,\n they have different names.\n")),
IsBinary: false,
},
{
- PathB: "tzu",
- LineStart: 1,
+ PathB: "tzu",
+ LineStart: 1,
+ Commit: &Commit{
+ Hash: "",
+ Author: "",
+ Date: newTime("0001-01-01 00:00:00 +0000 UTC"),
+ Message: strings.Builder{},
+ },
contentWriter: newBufferWithContent([]byte("The Nameless is the origin of Heaven and Earth;\nThe named is the mother of all things.\n\nTherefore let there always be non-being,\n so we may see their subtlety,\nAnd let there always be being,\n so we may see their outcome.\nThe two are the same,\nBut after they are produced,\n they have different names.\nThey both may be called deep and profound.\nDeeper and more profound,\nThe door of all subtleties!\n")),
IsBinary: false,
},
@@ -780,43 +798,85 @@ func TestStagedDiffParsing(t *testing.T) {
func TestStagedDiffParsingBufferedFileWriter(t *testing.T) {
expected := []*Diff{
{
- PathB: "aws",
- LineStart: 1,
+ PathB: "aws",
+ LineStart: 1,
+ Commit: &Commit{
+ Hash: "",
+ Author: "",
+ Date: newTime("0001-01-01 00:00:00 +0000 UTC"),
+ Message: strings.Builder{},
+ },
contentWriter: newBufferedFileWriterWithContent([]byte("[default]\naws_access_key_id = AKIAXYZDQCEN4B6JSJQI\naws_secret_access_key = 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\noutput = json\nregion = us-east-2\n")),
IsBinary: false,
},
{
- PathB: "aws2",
- LineStart: 1,
+ PathB: "aws2",
+ LineStart: 1,
+ Commit: &Commit{
+ Hash: "",
+ Author: "",
+ Date: newTime("0001-01-01 00:00:00 +0000 UTC"),
+ Message: strings.Builder{},
+ },
contentWriter: newBufferedFileWriterWithContent([]byte("\n\nthis is the secret: [Default]\nAccess key Id: AKIAILE3JG6KMS3HZGCA\nSecret Access Key: 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\n\nokay thank you bye\n")),
IsBinary: false,
},
{
- PathB: "core/runtime/src/main/java/io/quarkus/runtime/QuarkusApplication.java",
- LineStart: 3,
+ PathB: "core/runtime/src/main/java/io/quarkus/runtime/QuarkusApplication.java",
+ LineStart: 3,
+ Commit: &Commit{
+ Hash: "",
+ Author: "",
+ Date: newTime("0001-01-01 00:00:00 +0000 UTC"),
+ Message: strings.Builder{},
+ },
contentWriter: newBufferedFileWriterWithContent([]byte("/**\n * This is usually used for command mode applications with a startup logic. The logic is executed inside\n * {@link QuarkusApplication#run} method before the main application exits.\n */\n")),
IsBinary: false,
},
{
- PathB: "trufflehog_3.42.0_linux_arm64.tar.gz",
- IsBinary: true,
+ PathB: "trufflehog_3.42.0_linux_arm64.tar.gz",
+ IsBinary: true,
+ Commit: &Commit{
+ Hash: "",
+ Author: "",
+ Date: newTime("0001-01-01 00:00:00 +0000 UTC"),
+ Message: strings.Builder{},
+ },
contentWriter: newBufferedFileWriterWithContent(nil),
},
{
- PathB: "tzu",
- LineStart: 11,
+ PathB: "tzu",
+ LineStart: 11,
+ Commit: &Commit{
+ Hash: "",
+ Author: "",
+ Date: newTime("0001-01-01 00:00:00 +0000 UTC"),
+ Message: strings.Builder{},
+ },
contentWriter: newBufferedFileWriterWithContent([]byte("\n\n\n\nSource: https://www.gnu.org/software/diffutils/manual/diffutils.html#An-Example-of-Unified-Format\n")),
IsBinary: false,
},
{
- PathB: "lao",
- LineStart: 1,
+ PathB: "lao",
+ LineStart: 1,
+ Commit: &Commit{
+ Hash: "",
+ Author: "",
+ Date: newTime("0001-01-01 00:00:00 +0000 UTC"),
+ Message: strings.Builder{},
+ },
contentWriter: newBufferedFileWriterWithContent([]byte("The Way that can be told of is not the eternal Way;\nThe name that can be named is not the eternal name.\nThe Nameless is the origin of Heaven and Earth;\nThe Named is the mother of all things.\nTherefore let there always be non-being,\n so we may see their subtlety,\nAnd let there always be being,\n so we may see their outcome.\nThe two are the same,\nBut after they are produced,\n they have different names.\n")),
IsBinary: false,
},
{
- PathB: "tzu",
- LineStart: 1,
+ PathB: "tzu",
+ LineStart: 1,
+ Commit: &Commit{
+ Hash: "",
+ Author: "",
+ Date: newTime("0001-01-01 00:00:00 +0000 UTC"),
+ Message: strings.Builder{},
+ },
contentWriter: newBufferedFileWriterWithContent([]byte("The Nameless is the origin of Heaven and Earth;\nThe named is the mother of all things.\n\nTherefore let there always be non-being,\n so we may see their subtlety,\nAnd let there always be being,\n so we may see their outcome.\nThe two are the same,\nBut after they are produced,\n they have different names.\nThey both may be called deep and profound.\nDeeper and more profound,\nThe door of all subtleties!\n")),
IsBinary: false,
},
@@ -845,14 +905,34 @@ func TestStagedDiffParsingBufferedFileWriter(t *testing.T) {
func TestCommitParseFailureRecovery(t *testing.T) {
expected := []*Diff{
{
- PathB: ".travis.yml",
- LineStart: 1,
+ PathB: ".travis.yml",
+ LineStart: 1,
+ Commit: &Commit{
+ Hash: "df393b4125c2aa217211b2429b8963d0cefcee27",
+ Author: "Stephen <[email protected]>",
+ Date: newTime("Wed Dec 06 14:44:41 2017 -0800"),
+ Message: newStringBuilderValue("Add travis testing\n"),
+ },
contentWriter: newBufferWithContent([]byte("language: python\npython:\n - \"2.6\"\n - \"2.7\"\n - \"3.2\"\n - \"3.3\"\n - \"3.4\"\n - \"3.5\"\n - \"3.5-dev\" # 3.5 development branch\n - \"3.6\"\n - \"3.6-dev\" # 3.6 development branch\n - \"3.7-dev\" # 3.7 development branch\n - \"nightly\"\n")),
IsBinary: false,
},
{
- PathB: "tzu",
- LineStart: 11,
+ Commit: &Commit{
+ Hash: "3d76a97faad96e0f326afb61c232b9c2a18dca35",
+ Author: "John Smith <[email protected]>",
+ Date: newTime("Tue Jul 11 18:03:54 2023 -0400"),
+ Message: strings.Builder{},
+ },
+ },
+ {
+ PathB: "tzu",
+ LineStart: 11,
+ Commit: &Commit{
+ Hash: "7bd16429f1f708746dabf970e54b05d2b4734997",
+ Author: "John Smith <[email protected]>",
+ Date: newTime("Tue Jul 11 18:10:49 2023 -0400"),
+ Message: newStringBuilderValue("Change file\n"),
+ },
contentWriter: newBufferWithContent([]byte("\n\n\n\nSource: https://www.gnu.org/software/diffutils/manual/diffutils.html#An-Example-of-Unified-Format\n")),
IsBinary: false,
},
@@ -866,11 +946,6 @@ func TestCommitParseFailureRecovery(t *testing.T) {
}()
i := 0
for diff := range diffChan {
- if len(expected) <= i {
- t.Errorf("Missing expected case for commit: %+v", diff)
- break
- }
-
if !diff.Equal(context.Background(), expected[i]) {
t.Errorf("Diff does not match.\nexpected: %+v\n\nactual : %+v\n", expected[i], diff)
}
@@ -881,14 +956,34 @@ func TestCommitParseFailureRecovery(t *testing.T) {
func TestCommitParseFailureRecoveryBufferedFileWriter(t *testing.T) {
expected := []*Diff{
{
- PathB: ".travis.yml",
- LineStart: 1,
+ PathB: ".travis.yml",
+ LineStart: 1,
+ Commit: &Commit{
+ Hash: "df393b4125c2aa217211b2429b8963d0cefcee27",
+ Author: "Stephen <[email protected]>",
+ Date: newTime("Wed Dec 06 14:44:41 2017 -0800"),
+ Message: newStringBuilderValue("Add travis testing\n"),
+ },
contentWriter: newBufferedFileWriterWithContent([]byte("language: python\npython:\n - \"2.6\"\n - \"2.7\"\n - \"3.2\"\n - \"3.3\"\n - \"3.4\"\n - \"3.5\"\n - \"3.5-dev\" # 3.5 development branch\n - \"3.6\"\n - \"3.6-dev\" # 3.6 development branch\n - \"3.7-dev\" # 3.7 development branch\n - \"nightly\"\n")),
IsBinary: false,
},
{
- PathB: "tzu",
- LineStart: 11,
+ Commit: &Commit{
+ Hash: "3d76a97faad96e0f326afb61c232b9c2a18dca35",
+ Author: "John Smith <[email protected]>",
+ Date: newTime("Tue Jul 11 18:03:54 2023 -0400"),
+ Message: strings.Builder{},
+ },
+ },
+ {
+ PathB: "tzu",
+ LineStart: 11,
+ Commit: &Commit{
+ Hash: "7bd16429f1f708746dabf970e54b05d2b4734997",
+ Author: "John Smith <[email protected]>",
+ Date: newTime("Tue Jul 11 18:10:49 2023 -0400"),
+ Message: newStringBuilderValue("Change file\n"),
+ },
contentWriter: newBufferedFileWriterWithContent([]byte("\n\n\n\nSource: https://www.gnu.org/software/diffutils/manual/diffutils.html#An-Example-of-Unified-Format\n")),
IsBinary: false,
},
@@ -987,20 +1082,38 @@ index 5af88a8..c729cdb 100644
func TestDiffParseFailureRecovery(t *testing.T) {
expected := []*Diff{
{
- PathB: "aws",
- LineStart: 1,
+ PathB: "aws",
+ LineStart: 1,
+ Commit: &Commit{
+ Hash: "",
+ Author: "",
+ Date: newTime("0001-01-01 00:00:00 +0000 UTC"),
+ Message: strings.Builder{},
+ },
contentWriter: newBufferWithContent([]byte("[default]\naws_access_key_id = AKIAXYZDQCEN4B6JSJQI\naws_secret_access_key = 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\noutput = json\nregion = us-east-2\n")),
IsBinary: false,
},
{
- PathB: "tzu",
- LineStart: 11,
+ PathB: "tzu",
+ LineStart: 11,
+ Commit: &Commit{
+ Hash: "",
+ Author: "",
+ Date: newTime("0001-01-01 00:00:00 +0000 UTC"),
+ Message: strings.Builder{},
+ },
contentWriter: newBufferWithContent([]byte("\n\n\n\nSource: https://www.gnu.org/software/diffutils/manual/diffutils.html#An-Example-of-Unified-Format\n")),
IsBinary: false,
},
{
- PathB: "tzu",
- LineStart: 1,
+ PathB: "tzu",
+ LineStart: 1,
+ Commit: &Commit{
+ Hash: "",
+ Author: "",
+ Date: newTime("0001-01-01 00:00:00 +0000 UTC"),
+ Message: strings.Builder{},
+ },
contentWriter: newBufferWithContent([]byte("The Nameless is the origin of Heaven and Earth;\nThe named is the mother of all things.\n\nTherefore let there always be non-being,\n so we may see their subtlety,\nAnd let there always be being,\n so we may see their outcome.\nThe two are the same,\nBut after they are produced,\n they have different names.\nThey both may be called deep and profound.\nDeeper and more profound,\nThe door of all subtleties!\n")),
IsBinary: false,
},
@@ -1029,21 +1142,39 @@ func TestDiffParseFailureRecovery(t *testing.T) {
func TestDiffParseFailureRecoveryBufferedFileWriter(t *testing.T) {
expected := []*Diff{
{
- PathB: "aws",
- LineStart: 1,
- contentWriter: newBufferedFileWriterWithContent([]byte("[default]\naws_access_key_id = AKIAXYZDQCEN4B6JSJQI\naws_secret_access_key = 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\noutput = json\nregion = us-east-2\n")),
+ PathB: "aws",
+ LineStart: 1,
+ Commit: &Commit{
+ Hash: "",
+ Author: "",
+ Date: newTime("0001-01-01 00:00:00 +0000 UTC"),
+ Message: strings.Builder{},
+ },
+ contentWriter: newBufferWithContent([]byte("[default]\naws_access_key_id = AKIAXYZDQCEN4B6JSJQI\naws_secret_access_key = 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\noutput = json\nregion = us-east-2\n")),
IsBinary: false,
},
{
- PathB: "tzu",
- LineStart: 11,
- contentWriter: newBufferedFileWriterWithContent([]byte("\n\n\n\nSource: https://www.gnu.org/software/diffutils/manual/diffutils.html#An-Example-of-Unified-Format\n")),
+ PathB: "tzu",
+ LineStart: 11,
+ Commit: &Commit{
+ Hash: "",
+ Author: "",
+ Date: newTime("0001-01-01 00:00:00 +0000 UTC"),
+ Message: strings.Builder{},
+ },
+ contentWriter: newBufferWithContent([]byte("\n\n\n\nSource: https://www.gnu.org/software/diffutils/manual/diffutils.html#An-Example-of-Unified-Format\n")),
IsBinary: false,
},
{
- PathB: "tzu",
- LineStart: 1,
- contentWriter: newBufferedFileWriterWithContent([]byte("The Nameless is the origin of Heaven and Earth;\nThe named is the mother of all things.\n\nTherefore let there always be non-being,\n so we may see their subtlety,\nAnd let there always be being,\n so we may see their outcome.\nThe two are the same,\nBut after they are produced,\n they have different names.\nThey both may be called deep and profound.\nDeeper and more profound,\nThe door of all subtleties!\n")),
+ PathB: "tzu",
+ LineStart: 1,
+ Commit: &Commit{
+ Hash: "",
+ Author: "",
+ Date: newTime("0001-01-01 00:00:00 +0000 UTC"),
+ Message: strings.Builder{},
+ },
+ contentWriter: newBufferWithContent([]byte("The Nameless is the origin of Heaven and Earth;\nThe named is the mother of all things.\n\nTherefore let there always be non-being,\n so we may see their subtlety,\nAnd let there always be being,\n so we may see their outcome.\nThe two are the same,\nBut after they are produced,\n they have different names.\nThey both may be called deep and profound.\nDeeper and more profound,\nThe door of all subtleties!\n")),
IsBinary: false,
},
}
@@ -1204,7 +1335,12 @@ func TestMaxCommitSize(t *testing.T) {
}
-const diffLog = `
+const commitLog = `commit fd6e99e7a80199b76a694603be57c5ade1de18e7
+Author: Jaliborc <[email protected]>
+Date: Mon Apr 25 16:28:06 2011 +0100
+
+ Added Unusable coloring
+
diff --git a/components/item.lua b/components/item.lua
index fc74534..f8d7d50 100755
--- a/components/item.lua
@@ -1237,6 +1373,20 @@ new file mode 160000
@@ -0,0 +1 @@
+Subproject commit 0000000000000000000000000000000000000000
+commit 4727ffb7ad6dc5130bf4b4dd166e00705abdd018 (HEAD -> master)
+Author: John Smith <[email protected]>
+Date: Tue Jul 11 22:26:11 2023 -0400
+
+commit c904e0f5cd9f30ae520c66bd5f70806219fe7ca2 (HEAD -> master)
+Author: John Smith <[email protected]>
+Date: Mon Jul 10 10:17:11 2023 -0400
+
+ Empty Commit
+
+commit 3d76a97faad96e0f326afb61c232b9c2a18dca35 (HEAD -> master)
+Author: John Smith <[email protected]>
+Date: Tue Jul 11 18:03:54 2023 -0400
+
diff --git a/sample.txt b/sample.txt
new file mode 100644
index 0000000..af5626b
@@ -1245,6 +1395,12 @@ index 0000000..af5626b
@@ -0,0 +1 @@
+Hello, world!
+commit df393b4125c2aa217211b2429b8963d0cefcee27
+Author: Stephen <[email protected]>
+Date: Wed Dec 06 14:44:41 2017 -0800
+
+ Add travis testing
+
diff --git a/.gitignore b/.gitignore
index ede6aa39..bb85dcc3 100644
--- a/.gitignore
@@ -1279,6 +1435,12 @@ diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 00000000..e69de29b
+commit 4218c39d99b5f30153f62471c1be1c1596f0a4d4
+Author: Dustin Decker <[email protected]>
+Date: Thu Jan 13 12:02:24 2022 -0800
+
+ Initial CLI w/ partially implemented Git source and demo detector (#1)
+
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 00000000..e69de29b
@@ -1345,6 +1507,12 @@ index 0000000..451be67
+++ test
+
+commit 2a5d703b02b52d65c65ee9f7928f158b919ab741
+Author: Sergey Beryozkin <[email protected]>
+Date: Fri Jul 7 17:44:26 2023 +0100
+
+ Do not refresh OIDC session if the user is requesting logout
+
diff --git a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/BackChannelLogoutTokenCache.java b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/BackChannelLogoutTokenCache.java
index 096f5b4b092..4150096851c 100644
--- a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/BackChannelLogoutTokenCache.java
@@ -1447,6 +1615,14 @@ index 51e1b9a932d..472c2743bc4 100644
assertEquals("Welcome, clientId: quarkus-web-app", page.getBody().asNormalizedText());
assertNull(getSessionCookie(webClient, "code-flow"));
+commit 2a057632d7f5fa3d1c77b9aa037263211c0e0290
+Author: rjtmahinay <[email protected]>
+Date: Mon Jul 10 01:22:32 2023 +0800
+
+ Add QuarkusApplication javadoc
+
+ * Fix #34463
+
diff --git a/core/runtime/src/main/java/io/quarkus/runtime/QuarkusApplication.java b/core/runtime/src/main/java/io/quarkus/runtime/QuarkusApplication.java
index 350685123d5..87d2220eb98 100644
--- a/core/runtime/src/main/java/io/quarkus/runtime/QuarkusApplication.java
@@ -1457,20 +1633,44 @@ index 350685123d5..87d2220eb98 100644
+ * {@link QuarkusApplication#run} method before the main application exits.
+ */
+commit bca2d17491015ea1522f34517223b5a366aea73c (HEAD -> master)
+Author: John Smith <[email protected]>
+Date: Tue Jul 11 18:12:21 2023 -0400
+
+ Delete binary file
+
diff --git a/trufflehog_3.42.0_linux_arm64.tar.gz b/trufflehog_3.42.0_linux_arm64.tar.gz
deleted file mode 100644
index 7682212..0000000
Binary files a/trufflehog_3.42.0_linux_arm64.tar.gz and /dev/null differ
+commit afc6dc5d47f28366638da877ecb6b819c69e659b
+Author: John Smith <[email protected]>
+Date: Mon Jul 10 12:21:33 2023 -0400
+
+ Change binary file
+
diff --git a/trufflehog_3.42.0_linux_arm64.tar.gz b/trufflehog_3.42.0_linux_arm64.tar.gz
index 0a7a5b4..7682212 100644
Binary files a/trufflehog_3.42.0_linux_arm64.tar.gz and b/trufflehog_3.42.0_linux_arm64.tar.gz differ
+commit 638595917417c5c8a956937b28c5127719023363
+Author: John Smith <[email protected]>
+Date: Mon Jul 10 12:20:35 2023 -0400
+
+ Add binary file
+
diff --git a/trufflehog_3.42.0_linux_arm64.tar.gz b/trufflehog_3.42.0_linux_arm64.tar.gz
new file mode 100644
index 0000000..0a7a5b4
Binary files /dev/null and b/trufflehog_3.42.0_linux_arm64.tar.gz differ
+commit ce0f5d1fe0272f180ccb660196f439c0c2f4ec8e (HEAD -> master)
+Author: John Smith <[email protected]>
+Date: Tue Jul 11 18:08:52 2023 -0400
+
+ Delete file
+
diff --git a/lao b/lao
deleted file mode 100644
index 635ef2c..0000000
@@ -1489,11 +1689,23 @@ index 635ef2c..0000000
-But after they are produced,
- they have different names.
+commit d606a729383371558473b70a6a7b1ca264b0d205
+Author: John Smith <[email protected]>
+Date: Mon Jul 10 14:17:04 2023 -0400
+
+ Rename file
+
diff --git a/tzu b/tzu.txt
similarity index 100%
rename from tzu
rename to tzu.txt
+commit 7bd16429f1f708746dabf970e54b05d2b4734997 (HEAD -> master)
+Author: John Smith <[email protected]>
+Date: Tue Jul 11 18:10:49 2023 -0400
+
+ Change file
+
diff --git a/tzu b/tzu
index 5af88a8..c729cdb 100644
--- a/tzu
@@ -1505,6 +1717,12 @@ index 5af88a8..c729cdb 100644
+
+Source: https://www.gnu.org/software/diffutils/manual/diffutils.html#An-Example-of-Unified-Format
+commit c7062674c17192caa284615ab2fa9778c6602164 (HEAD -> master)
+Author: John Smith <[email protected]>
+Date: Mon Jul 10 10:15:18 2023 -0400
+
+ Create files
+
diff --git a/lao b/lao
new file mode 100644
index 0000000..635ef2c
@@ -1543,12 +1761,29 @@ index 0000000..5af88a8
+The door of all subtleties!
`
+func newTime(timestamp string) time.Time {
+ date, _ := time.Parse(defaultDateFormat, timestamp)
+ return date
+}
+
+func newStringBuilderValue(value string) strings.Builder {
+ builder := strings.Builder{}
+ builder.Write([]byte(value))
+ return builder
+}
+
// This throws a nasty panic if it's a top-level var.
func expectedDiffs() []*Diff {
return []*Diff{
{
- PathB: "components/item.lua",
- LineStart: 9,
+ PathB: "components/item.lua",
+ LineStart: 9,
+ Commit: &Commit{
+ Hash: "fd6e99e7a80199b76a694603be57c5ade1de18e7",
+ Author: "Jaliborc <[email protected]>",
+ Date: newTime("Mon Apr 25 16:28:06 2011 +0100"),
+ Message: newStringBuilderValue("Added Unusable coloring\n"),
+ },
contentWriter: newBufferWithContent([]byte("\n\nlocal Unfit = LibStub('Unfit-1.0')\n\n\n")),
IsBinary: false,
},
@@ -1556,29 +1791,75 @@ func expectedDiffs() []*Diff {
PathB: "embeds.xml",
LineStart: 6,
contentWriter: newBufferWithContent([]byte("\n\n <Script file=\"libs\\Unfit-1.0\\Unfit-1.0.lua\"/>\n\n\n\n")),
- IsBinary: false,
+ Commit: &Commit{
+ Hash: "fd6e99e7a80199b76a694603be57c5ade1de18e7",
+ Author: "Jaliborc <[email protected]>",
+ Date: newTime("Mon Apr 25 16:28:06 2011 +0100"),
+ Message: newStringBuilderValue("Added Unusable coloring\n"),
+ },
+ IsBinary: false,
},
{
PathB: "libs/Unfit-1.0",
LineStart: 1,
contentWriter: newBufferWithContent([]byte("Subproject commit 0000000000000000000000000000000000000000\n")),
- IsBinary: false,
+ Commit: &Commit{
+ Hash: "fd6e99e7a80199b76a694603be57c5ade1de18e7",
+ Author: "Jaliborc <[email protected]>",
+ Date: newTime("Mon Apr 25 16:28:06 2011 +0100"),
+ Message: newStringBuilderValue("Added Unusable coloring\n"),
+ },
+ IsBinary: false,
+ },
+ {
+ Commit: &Commit{
+ Hash: "4727ffb7ad6dc5130bf4b4dd166e00705abdd018",
+ Author: "John Smith <[email protected]>",
+ Date: newTime("Tue Jul 11 22:26:11 2023 -0400"),
+ Message: strings.Builder{},
+ },
+ },
+ {
+ Commit: &Commit{
+ Hash: "c904e0f5cd9f30ae520c66bd5f70806219fe7ca2",
+ Author: "John Smith <[email protected]>",
+ Date: newTime("Mon Jul 10 10:17:11 2023 -0400"),
+ Message: newStringBuilderValue("Empty Commit\n"),
+ },
},
{
PathB: "sample.txt",
LineStart: 1,
contentWriter: newBufferWithContent([]byte("Hello, world!\n")),
- IsBinary: false,
+ Commit: &Commit{
+ Hash: "3d76a97faad96e0f326afb61c232b9c2a18dca35",
+ Author: "John Smith <[email protected]>",
+ Date: newTime("Tue Jul 11 18:03:54 2023 -0400"),
+ Message: strings.Builder{},
+ },
+ IsBinary: false,
},
{
PathB: ".gitignore",
LineStart: 1,
contentWriter: newBufferWithContent([]byte("\n\n\n**/__pycache__/\n**/*.pyc\n")),
- IsBinary: false,
+ Commit: &Commit{
+ Hash: "df393b4125c2aa217211b2429b8963d0cefcee27",
+ Author: "Stephen <[email protected]>",
+ Date: newTime("Wed Dec 06 14:44:41 2017 -0800"),
+ Message: newStringBuilderValue("Add travis testing\n"),
+ },
+ IsBinary: false,
},
{
PathB: ".travis.yml",
LineStart: 1,
+ Commit: &Commit{
+ Hash: "df393b4125c2aa217211b2429b8963d0cefcee27",
+ Author: "Stephen <[email protected]>",
+ Date: newTime("Wed Dec 06 14:44:41 2017 -0800"),
+ Message: newStringBuilderValue("Add travis testing\n"),
+ },
contentWriter: newBufferWithContent([]byte(`language: python
python:
- "2.6"
@@ -1598,6 +1879,12 @@ python:
{
PathB: "Makefile",
LineStart: 1,
+ Commit: &Commit{
+ Hash: "4218c39d99b5f30153f62471c1be1c1596f0a4d4",
+ Author: "Dustin Decker <[email protected]>",
+ Date: newTime("Thu Jan 13 12:02:24 2022 -0800"),
+ Message: newStringBuilderValue("Initial CLI w/ partially implemented Git source and demo detector (#1)\n"),
+ },
contentWriter: newBufferWithContent([]byte(`PROTOS_IMAGE=us-docker.pkg.dev/thog-artifacts/public/go-ci-1.17-1
.PHONY: check
@@ -1634,79 +1921,181 @@ protos:
IsBinary: false,
},
{
- PathB: "plusLine.txt",
- LineStart: 1,
+ PathB: "plusLine.txt",
+ LineStart: 1,
+ Commit: &Commit{
+ Hash: "934cf5d255fd8e28b33f5a6ba64276caf0b284bf",
+ Author: "John Smith <[email protected]>",
+ Date: newTime("Tue Jul 11 18:43:22 2023 -0400"),
+ Message: newStringBuilderValue("Test toFile/plusLine parsing\n"),
+ },
contentWriter: newBufferWithContent([]byte("-- test\n++ test\n\n")),
IsBinary: false,
},
{
- PathB: "extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/BackChannelLogoutTokenCache.java",
- LineStart: 45,
+ PathB: "extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/BackChannelLogoutTokenCache.java",
+ LineStart: 45,
+ Commit: &Commit{
+ Hash: "2a5d703b02b52d65c65ee9f7928f158b919ab741",
+ Author: "Sergey Beryozkin <[email protected]>",
+ Date: newTime("Fri Jul 7 17:44:26 2023 +0100"),
+ Message: newStringBuilderValue("Do not refresh OIDC session if the user is requesting logout\n"),
+ },
contentWriter: newBufferWithContent([]byte("\n\n public boolean containsTokenVerification(String token) {\n return cacheMap.containsKey(token);\n }\n\n\n\n\n")),
IsBinary: false,
},
{
- PathB: "extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/CodeAuthenticationMechanism.java",
- LineStart: 1023,
+ PathB: "extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/CodeAuthenticationMechanism.java",
+ LineStart: 1023,
+ Commit: &Commit{
+ Hash: "2a5d703b02b52d65c65ee9f7928f158b919ab741",
+ Author: "Sergey Beryozkin <[email protected]>",
+ Date: newTime("Fri Jul 7 17:44:26 2023 +0100"),
+ Message: newStringBuilderValue("Do not refresh OIDC session if the user is requesting logout\n"),
+ },
contentWriter: newBufferWithContent([]byte("\n\n private boolean isRpInitiatedLogout(RoutingContext context, TenantConfigContext configContext) {\n\n\n")),
IsBinary: false,
},
{
- PathB: "extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/CodeAuthenticationMechanism.java",
- LineStart: 1214,
+ PathB: "extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/CodeAuthenticationMechanism.java",
+ LineStart: 1214,
+ Commit: &Commit{
+ Hash: "2a5d703b02b52d65c65ee9f7928f158b919ab741",
+ Author: "Sergey Beryozkin <[email protected]>",
+ Date: newTime("Fri Jul 7 17:44:26 2023 +0100"),
+ Message: newStringBuilderValue("Do not refresh OIDC session if the user is requesting logout\n"),
+ },
contentWriter: newBufferWithContent([]byte("\n\n\n\n private class LogoutCall implements Function<SecurityIdentity, Uni<?>> {\n RoutingContext context;\n TenantConfigContext configContext;\n String idToken;\n\n LogoutCall(RoutingContext context, TenantConfigContext configContext, String idToken) {\n this.context = context;\n this.configContext = configContext;\n this.idToken = idToken;\n }\n\n @Override\n public Uni<Void> apply(SecurityIdentity identity) {\n if (isRpInitiatedLogout(context, configContext)) {\n LOG.debug(\"Performing an RP initiated logout\");\n fireEvent(SecurityEvent.Type.OIDC_LOGOUT_RP_INITIATED, identity);\n return buildLogoutRedirectUriUni(context, configContext, idToken);\n }\n if (isBackChannelLogoutPendingAndValid(configContext, identity)\n || isFrontChannelLogoutValid(context, configContext,\n identity)) {\n return removeSessionCookie(context, configContext.oidcConfig)\n .map(new Function<Void, Void>() {\n @Override\n public Void apply(Void t) {\n throw new LogoutException();\n }\n });\n\n }\n return VOID_UNI;\n }\n }\n\n")),
IsBinary: false,
},
{
- PathB: "integration-tests/oidc-wiremock/src/main/resources/application.properties",
- LineStart: 20,
+ PathB: "integration-tests/oidc-wiremock/src/main/resources/application.properties",
+ LineStart: 20,
+ Commit: &Commit{
+ Hash: "2a5d703b02b52d65c65ee9f7928f158b919ab741",
+ Author: "Sergey Beryozkin <[email protected]>",
+ Date: newTime("Fri Jul 7 17:44:26 2023 +0100"),
+ Message: newStringBuilderValue("Do not refresh OIDC session if the user is requesting logout\n"),
+ },
contentWriter: newBufferWithContent([]byte("\n\n\nquarkus.oidc.code-flow.token.refresh-expired=true\nquarkus.oidc.code-flow.token.refresh-token-time-skew=5M\n\n\n")),
IsBinary: false,
},
// WTF, shouldn't this be filtered out?
{
- PathB: "integration-tests/oidc-wiremock/src/test/java/io/quarkus/it/keycloak/CodeFlowAuthorizationTest.java",
- LineStart: 6,
+ PathB: "integration-tests/oidc-wiremock/src/test/java/io/quarkus/it/keycloak/CodeFlowAuthorizationTest.java",
+ LineStart: 6,
+ Commit: &Commit{
+ Hash: "2a5d703b02b52d65c65ee9f7928f158b919ab741",
+ Author: "Sergey Beryozkin <[email protected]>",
+ Date: newTime("Fri Jul 7 17:44:26 2023 +0100"),
+ Message: newStringBuilderValue("Do not refresh OIDC session if the user is requesting logout\n"),
+ },
contentWriter: newBufferWithContent([]byte("\n\n\n\n\n\n")),
IsBinary: false,
},
{
- PathB: "integration-tests/oidc-wiremock/src/test/java/io/quarkus/it/keycloak/CodeFlowAuthorizationTest.java",
- LineStart: 76,
+ PathB: "integration-tests/oidc-wiremock/src/test/java/io/quarkus/it/keycloak/CodeFlowAuthorizationTest.java",
+ LineStart: 76,
+ Commit: &Commit{
+ Hash: "2a5d703b02b52d65c65ee9f7928f158b919ab741",
+ Author: "Sergey Beryozkin <[email protected]>",
+ Date: newTime("Fri Jul 7 17:44:26 2023 +0100"),
+ Message: newStringBuilderValue("Do not refresh OIDC session if the user is requesting logout\n"),
+ },
contentWriter: newBufferWithContent([]byte("\n\n // Logout\n\n\n\n")),
IsBinary: false,
},
{
- PathB: "core/runtime/src/main/java/io/quarkus/runtime/QuarkusApplication.java",
- LineStart: 3,
+ PathB: "core/runtime/src/main/java/io/quarkus/runtime/QuarkusApplication.java",
+ LineStart: 3,
+ Commit: &Commit{
+ Hash: "2a057632d7f5fa3d1c77b9aa037263211c0e0290",
+ Author: "rjtmahinay <[email protected]>",
+ Date: newTime("Mon Jul 10 01:22:32 2023 +0800"),
+ Message: newStringBuilderValue("Add QuarkusApplication javadoc\n\n* Fix #34463\n"),
+ },
contentWriter: newBufferWithContent([]byte("/**\n * This is usually used for command mode applications with a startup logic. The logic is executed inside\n * {@link QuarkusApplication#run} method before the main application exits.\n */\n")),
IsBinary: false,
},
{
- PathB: "trufflehog_3.42.0_linux_arm64.tar.gz",
+ Commit: &Commit{
+ Hash: "bca2d17491015ea1522f34517223b5a366aea73c",
+ Author: "John Smith <[email protected]>",
+ Date: newTime("Tue Jul 11 18:12:21 2023 -0400"),
+ Message: newStringBuilderValue("Delete binary file\n"),
+ },
+ },
+ {
+ PathB: "trufflehog_3.42.0_linux_arm64.tar.gz",
+ Commit: &Commit{
+ Hash: "afc6dc5d47f28366638da877ecb6b819c69e659b",
+ Author: "John Smith <[email protected]>",
+ Date: newTime("Mon Jul 10 12:21:33 2023 -0400"),
+ Message: newStringBuilderValue("Change binary file\n"),
+ },
contentWriter: newBufferWithContent([]byte("")),
IsBinary: true,
},
{
- PathB: "trufflehog_3.42.0_linux_arm64.tar.gz",
+ PathB: "trufflehog_3.42.0_linux_arm64.tar.gz",
+ Commit: &Commit{
+ Hash: "638595917417c5c8a956937b28c5127719023363",
+ Author: "John Smith <[email protected]>",
+ Date: newTime("Mon Jul 10 12:20:35 2023 -0400"),
+ Message: newStringBuilderValue("Add binary file\n"),
+ },
contentWriter: newBufferWithContent([]byte("")),
IsBinary: true,
},
{
- PathB: "tzu",
- LineStart: 11,
+ Commit: &Commit{
+ Hash: "ce0f5d1fe0272f180ccb660196f439c0c2f4ec8e",
+ Author: "John Smith <[email protected]>",
+ Date: newTime("Tue Jul 11 18:08:52 2023 -0400"),
+ Message: newStringBuilderValue("Delete file\n"),
+ },
+ },
+ {
+ Commit: &Commit{
+ Hash: "d606a729383371558473b70a6a7b1ca264b0d205",
+ Author: "John Smith <[email protected]>",
+ Date: newTime("Mon Jul 10 14:17:04 2023 -0400"),
+ Message: newStringBuilderValue("Rename file\n"),
+ },
+ },
+ {
+ PathB: "tzu",
+ LineStart: 11,
+ Commit: &Commit{
+ Hash: "7bd16429f1f708746dabf970e54b05d2b4734997",
+ Author: "John Smith <[email protected]>",
+ Date: newTime("Tue Jul 11 18:10:49 2023 -0400"),
+ Message: newStringBuilderValue("Change file\n"),
+ },
contentWriter: newBufferWithContent([]byte("\n\n\n\nSource: https://www.gnu.org/software/diffutils/manual/diffutils.html#An-Example-of-Unified-Format\n")),
IsBinary: false,
},
{
- PathB: "lao",
- LineStart: 1,
+ PathB: "lao",
+ LineStart: 1,
+ Commit: &Commit{
+ Hash: "c7062674c17192caa284615ab2fa9778c6602164",
+ Author: "John Smith <[email protected]>",
+ Date: newTime("Mon Jul 10 10:15:18 2023 -0400"),
+ Message: newStringBuilderValue("Create files\n"),
+ },
contentWriter: newBufferWithContent([]byte("The Way that can be told of is not the eternal Way;\nThe name that can be named is not the eternal name.\nThe Nameless is the origin of Heaven and Earth;\nThe Named is the mother of all things.\nTherefore let there always be non-being,\n so we may see their subtlety,\nAnd let there always be being,\n so we may see their outcome.\nThe two are the same,\nBut after they are produced,\n they have different names.\n")),
IsBinary: false,
},
{
- PathB: "tzu",
- LineStart: 1,
+ PathB: "tzu",
+ LineStart: 1,
+ Commit: &Commit{
+ Hash: "c7062674c17192caa284615ab2fa9778c6602164",
+ Author: "John Smith <[email protected]>",
+ Date: newTime("Mon Jul 10 10:15:18 2023 -0400"),
+ Message: newStringBuilderValue("Create files\n"),
+ },
contentWriter: newBufferWithContent([]byte("The Nameless is the origin of Heaven and Earth;\nThe named is the mother of all things.\n\nTherefore let there always be non-being,\n so we may see their subtlety,\nAnd let there always be being,\n so we may see their outcome.\nThe two are the same,\nBut after they are produced,\n they have different names.\nThey both may be called deep and profound.\nDeeper and more profound,\nThe door of all subtleties!\n")),
IsBinary: false,
},
diff --git a/pkg/sources/git/git.go b/pkg/sources/git/git.go
index d4577d28a..d9596328f 100644
--- a/pkg/sources/git/git.go
+++ b/pkg/sources/git/git.go
@@ -522,6 +522,18 @@ func (s *Git) ScanCommits(ctx context.Context, repo *git.Repository, path string
repoCtx = context.WithValue(ctx, "repo", path)
}
+ logger := repoCtx.Logger()
+ var logValues []any
+ if scanOptions.BaseHash != "" {
+ logValues = append(logValues, "base", scanOptions.BaseHash)
+ }
+ if scanOptions.HeadHash != "" {
+ logValues = append(logValues, "head", scanOptions.HeadHash)
+ }
+ if scanOptions.MaxDepth > 0 {
+ logValues = append(logValues, "max_depth", scanOptions.MaxDepth)
+ }
+
diffChan, err := s.parser.RepoPath(repoCtx, path, scanOptions.HeadHash, scanOptions.BaseHash == "", scanOptions.ExcludeGlobs, scanOptions.Bare)
if err != nil {
return err
@@ -532,14 +544,6 @@ func (s *Git) ScanCommits(ctx context.Context, repo *git.Repository, path string
gitDir := filepath.Join(path, gitDirName)
- logger := repoCtx.Logger()
- var logValues []any
- if scanOptions.BaseHash != "" {
- logValues = append(logValues, "base", scanOptions.BaseHash)
- }
- if scanOptions.HeadHash != "" {
- logValues = append(logValues, "head", scanOptions.HeadHash)
- }
logger.V(1).Info("scanning repo", logValues...)
var depth int64
@@ -551,18 +555,17 @@ func (s *Git) ScanCommits(ctx context.Context, repo *git.Repository, path string
}
fullHash := diff.Commit.Hash
- if !strings.EqualFold(fullHash, lastCommitHash) {
+ if scanOptions.BaseHash != "" && scanOptions.BaseHash == fullHash {
+ logger.V(1).Info("reached base commit", "commit", fullHash)
+ break
+ }
+
+ if fullHash != lastCommitHash {
depth++
lastCommitHash = fullHash
atomic.AddUint64(&s.metrics.commitsScanned, 1)
logger.V(5).Info("scanning commit", "commit", fullHash)
}
- if len(scanOptions.BaseHash) > 0 {
- if fullHash == scanOptions.BaseHash {
- logger.V(1).Info("reached base commit", "commit", fullHash)
- break
- }
- }
if !scanOptions.Filter.Pass(diff.PathB) {
continue
@@ -733,7 +736,7 @@ func (s *Git) ScanStaged(ctx context.Context, repo *git.Repository, path string,
// Get the URL metadata for reporting (may be empty).
urlMetadata := getSafeRemoteURL(repo, "origin")
- diffChan, err := gitparse.NewParser().Staged(ctx, path)
+ diffChan, err := s.parser.Staged(ctx, path)
if err != nil {
return err
}
@@ -744,6 +747,19 @@ func (s *Git) ScanStaged(ctx context.Context, repo *git.Repository, path string,
reachedBase := false
gitDir := filepath.Join(path, gitDirName)
+ logger := ctx.Logger()
+ var logValues []any
+ if scanOptions.BaseHash != "" {
+ logValues = append(logValues, "base", scanOptions.BaseHash)
+ }
+ if scanOptions.HeadHash != "" {
+ logValues = append(logValues, "head", scanOptions.HeadHash)
+ }
+ if scanOptions.MaxDepth > 0 {
+ logValues = append(logValues, "max_depth", scanOptions.MaxDepth)
+ }
+ logger.V(1).Info("scanning repo", logValues...)
+
ctx.Logger().V(1).Info("scanning staged changes", "path", path)
var depth int64
@@ -758,21 +774,19 @@ func (s *Git) ScanStaged(ctx context.Context, repo *git.Repository, path string,
break
}
- if !strings.EqualFold(fullHash, lastCommitHash) {
+ if fullHash != lastCommitHash {
depth++
lastCommitHash = fullHash
atomic.AddUint64(&s.metrics.commitsScanned, 1)
}
- if reachedBase && !strings.EqualFold(fullHash, scanOptions.BaseHash) {
+ if reachedBase && fullHash != scanOptions.BaseHash {
break
}
- if len(scanOptions.BaseHash) > 0 {
- if strings.EqualFold(fullHash, scanOptions.BaseHash) {
- logger.V(1).Info("reached base hash, finishing scanning files")
- reachedBase = true
- }
+ if scanOptions.BaseHash != "" && fullHash == scanOptions.BaseHash {
+ logger.V(1).Info("reached base hash, finishing scanning files")
+ reachedBase = true
}
if !scanOptions.Filter.Pass(diff.PathB) {