Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7798005fd5 | |||
| 32555f5e87 | |||
| f3071aa46a | |||
| ea2de122be | |||
| 83e22d8b16 |
+3
-2
@@ -27,9 +27,10 @@ runs:
|
||||
- git
|
||||
- file://${{ inputs.path }}
|
||||
- --since-commit
|
||||
- ${{ inputs.base }}
|
||||
- ${{ inputs.base.default }}
|
||||
- --branch
|
||||
- ${{ inputs.head }}
|
||||
- --fail
|
||||
- --no-update
|
||||
- ${{ inputs.extra_args }}
|
||||
- ${{arg in inputs.extra_args.split(' ')}}${{arg}}${{end}}
|
||||
- ${{ arg }}
|
||||
+2
-3
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env ash
|
||||
|
||||
# `$*` expands the `args` supplied in an `array` individually
|
||||
# or splits `args` in a string separated by whitespace.
|
||||
/usr/bin/trufflehog $*
|
||||
# "$@" should expand all args in an 'array' as they were passed in
|
||||
/usr/bin/trufflehog "$@"
|
||||
+8
-17
@@ -9,7 +9,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"github.com/trufflesecurity/trufflehog/v3/pkg/common"
|
||||
"github.com/trufflesecurity/trufflehog/v3/pkg/context"
|
||||
@@ -182,6 +181,7 @@ func (e *Engine) detectorWorker(ctx context.Context) {
|
||||
for originalChunk := range e.chunks {
|
||||
for chunk := range sources.Chunker(originalChunk) {
|
||||
atomic.AddUint64(&e.bytesScanned, uint64(len(chunk.Data)))
|
||||
fragStart, mdLine := FragmentFirstLine(chunk)
|
||||
for _, decoder := range e.decoders {
|
||||
var decoderType detectorspb.DecoderType
|
||||
switch decoder.(type) {
|
||||
@@ -230,19 +230,9 @@ func (e *Engine) detectorWorker(ctx context.Context) {
|
||||
results = detectors.CleanResults(results)
|
||||
}
|
||||
for _, result := range results {
|
||||
resultChunk := chunk
|
||||
if SupportsLineNumbers(chunk.SourceType) {
|
||||
copyChunk := *chunk
|
||||
copyMetaDataClone := proto.Clone(chunk.SourceMetadata)
|
||||
if copyMetaData, ok := copyMetaDataClone.(*source_metadatapb.MetaData); ok {
|
||||
copyChunk.SourceMetadata = copyMetaData
|
||||
}
|
||||
fragStart, mdLine := FragmentFirstLine(©Chunk)
|
||||
SetResultLineNumber(©Chunk, &result, fragStart, mdLine)
|
||||
resultChunk = ©Chunk
|
||||
}
|
||||
SetResultLineNumber(chunk, &result, fragStart, mdLine)
|
||||
result.DecoderType = decoderType
|
||||
e.results <- detectors.CopyMetadata(resultChunk, result)
|
||||
e.results <- detectors.CopyMetadata(chunk, result)
|
||||
|
||||
}
|
||||
if len(results) > 0 {
|
||||
@@ -281,8 +271,7 @@ func gitSources() []sourcespb.SourceType {
|
||||
}
|
||||
}
|
||||
|
||||
// SupportsLineNumbers determines if a line number can be found for a source type.
|
||||
func SupportsLineNumbers(sourceType sourcespb.SourceType) bool {
|
||||
func isGitSource(sourceType sourcespb.SourceType) bool {
|
||||
for _, i := range gitSources() {
|
||||
if i == sourceType {
|
||||
return true
|
||||
@@ -325,6 +314,8 @@ func FragmentFirstLine(chunk *sources.Chunk) (int64, *int64) {
|
||||
|
||||
// SetResultLineNumber sets the line number in the provided result.
|
||||
func SetResultLineNumber(chunk *sources.Chunk, result *detectors.Result, fragStart int64, mdLine *int64) {
|
||||
offset := FragmentLineOffset(chunk, result)
|
||||
*mdLine = fragStart + offset
|
||||
if isGitSource(chunk.SourceType) {
|
||||
offset := FragmentLineOffset(chunk, result)
|
||||
*mdLine = fragStart + offset
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user