Compare commits

..

5 Commits

Author SHA1 Message Date
Ahrav Dutta 7798005fd5 Update loop. 2023-01-09 16:45:04 -08:00
Ahrav Dutta 32555f5e87 Call each extra arg on its own. 2023-01-09 16:30:46 -08:00
ahrav f3071aa46a Merge branch 'main' into update-entrypoint-script 2023-01-09 15:46:51 -08:00
Ahrav Dutta ea2de122be update comment. 2023-01-09 15:46:41 -08:00
Ahrav Dutta 83e22d8b16 Update entrypoint. 2023-01-09 12:17:33 -08:00
3 changed files with 13 additions and 22 deletions
+3 -2
View File
@@ -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
View File
@@ -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
View File
@@ -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(&copyChunk)
SetResultLineNumber(&copyChunk, &result, fragStart, mdLine)
resultChunk = &copyChunk
}
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
}
}