Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 477e2a1332 | |||
| 430d5c764c | |||
| 8b2e1d36cf | |||
| 864cf00337 |
+1
-1
@@ -9,7 +9,7 @@ RUN --mount=type=cache,target=/go/pkg/mod \
|
||||
GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o trufflehog .
|
||||
|
||||
FROM alpine:3.15
|
||||
RUN apk add --no-cache git ca-certificates \
|
||||
RUN apk add --no-cache bash git ca-certificates \
|
||||
&& rm -rf /var/cache/apk/* && \
|
||||
update-ca-certificates
|
||||
COPY --from=builder /build/trufflehog /usr/bin/trufflehog
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
FROM alpine:3.15
|
||||
|
||||
RUN apk add --no-cache git ca-certificates \
|
||||
RUN apk add --no-cache bash git ca-certificates \
|
||||
&& rm -rf /var/cache/apk/* && \
|
||||
update-ca-certificates
|
||||
WORKDIR /usr/bin/
|
||||
|
||||
+2
-3
@@ -27,10 +27,9 @@ runs:
|
||||
- git
|
||||
- file://${{ inputs.path }}
|
||||
- --since-commit
|
||||
- ${{ inputs.base.default }}
|
||||
- ${{ inputs.base }}
|
||||
- --branch
|
||||
- ${{ inputs.head }}
|
||||
- --fail
|
||||
- --no-update
|
||||
- ${{arg in inputs.extra_args.split(' ')}}${{arg}}${{end}}
|
||||
- ${{ arg }}
|
||||
- ${{ inputs.extra_args }}
|
||||
|
||||
+5
-3
@@ -1,4 +1,6 @@
|
||||
#!/usr/bin/env ash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# "$@" should expand all args in an 'array' as they were passed in
|
||||
/usr/bin/trufflehog "$@"
|
||||
# Parse the last argument into an array of extra_args.
|
||||
mapfile -t extra_args < <(bash -c "for arg in ${*: -1}; do echo \$arg; done")
|
||||
|
||||
/usr/bin/trufflehog "${@: 1: $#-1}" "${extra_args[@]}"
|
||||
+17
-8
@@ -9,6 +9,7 @@ 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"
|
||||
@@ -181,7 +182,6 @@ 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,9 +230,19 @@ func (e *Engine) detectorWorker(ctx context.Context) {
|
||||
results = detectors.CleanResults(results)
|
||||
}
|
||||
for _, result := range results {
|
||||
SetResultLineNumber(chunk, &result, fragStart, mdLine)
|
||||
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
|
||||
}
|
||||
result.DecoderType = decoderType
|
||||
e.results <- detectors.CopyMetadata(chunk, result)
|
||||
e.results <- detectors.CopyMetadata(resultChunk, result)
|
||||
|
||||
}
|
||||
if len(results) > 0 {
|
||||
@@ -271,7 +281,8 @@ func gitSources() []sourcespb.SourceType {
|
||||
}
|
||||
}
|
||||
|
||||
func isGitSource(sourceType sourcespb.SourceType) bool {
|
||||
// SupportsLineNumbers determines if a line number can be found for a source type.
|
||||
func SupportsLineNumbers(sourceType sourcespb.SourceType) bool {
|
||||
for _, i := range gitSources() {
|
||||
if i == sourceType {
|
||||
return true
|
||||
@@ -314,8 +325,6 @@ 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) {
|
||||
if isGitSource(chunk.SourceType) {
|
||||
offset := FragmentLineOffset(chunk, result)
|
||||
*mdLine = fragStart + offset
|
||||
}
|
||||
offset := FragmentLineOffset(chunk, result)
|
||||
*mdLine = fragStart + offset
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user