Skip to content

Commit 5c348c2

Browse files
committed
Merge branch 'refs/heads/main' into release-2.5
# Conflicts: # go.mod # go.sum
2 parents 3a9b485 + a655535 commit 5c348c2

28 files changed

Lines changed: 258 additions & 427 deletions

Dockerfile

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ ARG VECTORSCAN_IMG_TAG=latest
22
ARG VECTORSCAN_IMAGE_REPOSITORY=deepfenceio
33
FROM $VECTORSCAN_IMAGE_REPOSITORY/deepfence_vectorscan_build:$VECTORSCAN_IMG_TAG AS vectorscan
44

5-
FROM golang:1.23-alpine3.20 AS builder
6-
MAINTAINER DeepFence
5+
FROM golang:1.25-alpine3.23 AS builder
6+
LABEL maintainer="DeepFence"
77

88
RUN apk update \
9-
&& apk add --upgrade gcc musl-dev pkgconfig g++ make git
9+
&& apk add --upgrade gcc musl-dev pkgconfig g++ make git curl
1010

1111
RUN apk add --no-cache \
1212
git \
@@ -38,48 +38,62 @@ RUN apk add --no-cache -t .build-deps py-setuptools \
3838
libmagic-static \
3939
linux-headers
4040

41-
RUN cd /root && wget https://github.com/VirusTotal/yara/archive/refs/tags/v4.3.2.tar.gz \
42-
&& tar -zxf v4.3.2.tar.gz \
43-
&& cd yara-4.3.2 \
41+
RUN cd /root && wget https://github.com/VirusTotal/yara/archive/refs/tags/v4.5.5.tar.gz \
42+
&& tar -zxf v4.5.5.tar.gz \
43+
&& cd yara-4.5.5 \
4444
&& ./bootstrap.sh \
4545
&& ./configure --prefix=/usr/local/yara --disable-dotnet --enable-magic --enable-cuckoo --disable-shared --enable-static\
4646
&& make \
4747
&& make install \
4848
&& cd /usr/local/ \
4949
&& tar -czf yara.tar.gz yara
5050

51+
# Copy YaraHunter first (for local replace directive)
52+
WORKDIR /home/deepfence/src
53+
COPY YaraHunter/ YaraHunter/
54+
5155
WORKDIR /home/deepfence/src/SecretScanner
52-
COPY . .
56+
COPY SecretScanner/ .
5357
RUN make clean && make all
5458

55-
FROM alpine:3.20
56-
MAINTAINER DeepFence
59+
# Download rules and convert to yar format
60+
RUN mkdir -p /home/deepfence/rules \
61+
&& curl -fsSL https://artifacts.threatmapper.org/threat-intel/secret/secret_v2.5.8.tar.gz \
62+
-o /tmp/secret_rules.tar.gz \
63+
&& tar -xzf /tmp/secret_rules.tar.gz -C /home/deepfence/rules --strip-components=1 \
64+
&& rm /tmp/secret_rules.tar.gz
65+
66+
# Build and run the converter
67+
WORKDIR /home/deepfence/src/SecretScanner
68+
RUN go run ./cmd/convert-rules/main.go /home/deepfence/rules/df-secret.json /home/deepfence/rules/secret.yar
69+
70+
71+
FROM alpine:3.23
72+
LABEL maintainer="DeepFence"
5773
LABEL deepfence.role=system
5874

5975
ENV MGMT_CONSOLE_URL=deepfence-internal-router \
6076
MGMT_CONSOLE_PORT=443
6177

6278
ARG TARGETARCH
6379

64-
RUN apk add --no-cache --upgrade tar libstdc++ libgcc docker skopeo bash podman
80+
RUN apk add --no-cache --upgrade tar libstdc++ libgcc docker skopeo bash podman curl
6581

6682
RUN <<EOF
6783
set -eux
6884

69-
apk update && apk add --no-cache --upgrade curl
70-
71-
NERDCTL_VERSION=1.7.7
85+
NERDCTL_VERSION=2.2.0
7286
curl -fsSLO https://github.com/containerd/nerdctl/releases/download/v${NERDCTL_VERSION}/nerdctl-${NERDCTL_VERSION}-linux-${TARGETARCH}.tar.gz
7387
tar Cxzvvf /usr/local/bin nerdctl-${NERDCTL_VERSION}-linux-${TARGETARCH}.tar.gz
7488
rm nerdctl-${NERDCTL_VERSION}-linux-${TARGETARCH}.tar.gz
7589

76-
apk del curl
7790
EOF
7891

7992
WORKDIR /home/deepfence/usr
8093
COPY --from=builder /home/deepfence/src/SecretScanner/SecretScanner .
8194
COPY --from=builder /home/deepfence/src/SecretScanner/config.yaml .
95+
COPY --from=builder /home/deepfence/rules/secret.yar .
8296
WORKDIR /home/deepfence/output
8397

84-
ENTRYPOINT ["/home/deepfence/usr/SecretScanner", "-config-path", "/home/deepfence/usr"]
98+
ENTRYPOINT ["/home/deepfence/usr/SecretScanner", "-config-path", "/home/deepfence/usr", "-rules-path", "/home/deepfence/usr"]
8599
CMD ["-h"]

MAINTAINERS.md

Lines changed: 0 additions & 17 deletions
This file was deleted.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export IMAGE_REPOSITORY?=quay.io/deepfenceio
2-
export DF_IMG_TAG?=2.5.7
2+
export DF_IMG_TAG?=2.5.8
33

44
all: SecretScanner
55

README.md

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
# SecretScanner
22

3-
[![Documentation](https://img.shields.io/badge/documentation-read-green)](https://community.deepfence.io/docs/secretscanner/)
3+
[![Documentation](https://img.shields.io/badge/documentation-read-green)](https://threatmapper.org/docs/secretscanner/)
44
[![GitHub license](https://img.shields.io/github/license/deepfence/SecretScanner)](https://github.com/deepfence/SecretScanner/blob/master/LICENSE)
55
[![GitHub stars](https://img.shields.io/github/stars/deepfence/SecretScanner)](https://github.com/deepfence/SecretScanner/stargazers)
6-
[![Hacktoberfest](https://img.shields.io/github/hacktoberfest/2022/deepfence/SecretScanner)](https://github.com/deepfence/SecretScanner/issues)
76
[![GitHub issues](https://img.shields.io/github/issues/deepfence/SecretScanner)](https://github.com/deepfence/SecretScanner/issues)
87
[![Slack](https://img.shields.io/badge/slack-@deepfence-blue.svg?logo=slack)](https://join.slack.com/t/deepfence-community/shared_invite/zt-podmzle9-5X~qYx8wMaLt9bGWwkSdgQ)
9-
[![Twitter](https://img.shields.io/twitter/url?style=social&url=https%3A%2F%2Fgithub.com%2Fdeepfence%2FSecretScanner)](https://twitter.com/intent/tweet?text=Check%20this%20out%3A&url=https%3A%2F%2Fgithub.com%2Fdeepfence%2FSecretScanner)
108

119
# SecretScanner
1210

@@ -29,7 +27,7 @@ Use SecretScanner if you need a lightweight, efficient method to scan container
2927

3028
## Quick Start
3129

32-
For full instructions, refer to the [SecretScanner Documentation](https://community.deepfence.io/docs/secretscanner/).
30+
For full instructions, refer to the [SecretScanner Documentation](https://threatmapper.org/docs/secretscanner/).
3331

3432
![SecretScanner QuickStart](docs/docs/secretscanner/img/secretscanner.svg)
3533

@@ -38,19 +36,12 @@ Install docker and run SecretScanner on a container image using the following in
3836
* Build SecretScanner:
3937
```shell
4038
./bootstrap.sh
41-
docker build --rm=true --tag=quay.io/deepfenceio/deepfence_secret_scanner_ce:2.5.7 -f Dockerfile .
39+
docker build --rm=true --tag=quay.io/deepfenceio/deepfence_secret_scanner_ce:2.5.8 -f Dockerfile .
4240
```
4341

4442
* Or, pull the latest build from docker hub by doing:
4543
```shell
46-
docker pull quay.io/deepfenceio/deepfence_secret_scanner_ce:2.5.7
47-
```
48-
49-
### Generate License Key
50-
51-
Run this command to generate a license key. Work/official email id has to be used.
52-
```shell
53-
curl https://license.deepfence.io/threatmapper/generate-license?first_name=<FIRST_NAME>&last_name=<LAST_NAME>&email=<EMAIL>&company=<ORGANIZATION_NAME>&resend_email=true
44+
docker pull quay.io/deepfenceio/deepfence_secret_scanner_ce:2.5.8
5445
```
5546

5647
### Scan
@@ -60,30 +51,15 @@ curl https://license.deepfence.io/threatmapper/generate-license?first_name=<FIRS
6051
docker pull node:8.11
6152
```
6253

63-
* Set Product and Licence and scan it::
54+
* Scan it:
6455
```shell
6556
docker run -i --rm --name=deepfence-secretscanner \
66-
-e DEEPFENCE_PRODUCT=<ThreatMapper or ThreatStryker> \
67-
-e DEEPFENCE_LICENSE=<ThreatMapper or ThreatStryker license key> \
6857
-v /var/run/docker.sock:/var/run/docker.sock \
69-
quay.io/deepfenceio/deepfence_secret_scanner_ce:2.5.7 \
58+
quay.io/deepfenceio/deepfence_secret_scanner_ce:2.5.8 \
7059
--image-name node:8.11 \
7160
--output json > node.json
7261
```
7362

74-
Rules can also be cached to use next run by mounting a seperate path and passing `rules-path` argument
75-
```shell
76-
docker run -i --rm --name=deepfence-yarahunter \
77-
-e DEEPFENCE_PRODUCT=<ThreatMapper or ThreatStryker> \
78-
-e DEEPFENCE_LICENSE=<ThreatMapper or ThreatStryker license key> \
79-
-v /var/run/docker.sock:/var/run/docker.sock \
80-
-v /tmp/rules:/tmp/rules \
81-
quay.io/deepfenceio/deepfence_secret_scanner_ce:2.5.7 \
82-
--image-name node:8.11 \
83-
--rules-path=/tmp/rules \
84-
--output json > node.json
85-
```
86-
8763
# Credits
8864

8965
We have built upon the configuration file from [shhgit](https://github.com/eth0izzle/shhgit) project.
@@ -92,11 +68,10 @@ We have built upon the configuration file from [shhgit](https://github.com/eth0i
9268

9369
Thank you for using SecretScanner.
9470

95-
* [<img src="https://img.shields.io/badge/documentation-read-green">](https://community.deepfence.io/docs/secretscanner/) Start with the documentation
71+
* [<img src="https://img.shields.io/badge/documentation-read-green">](https://threatmapper.org/docs/secretscanner/) Start with the documentation
9672
* [<img src="https://img.shields.io/badge/slack-@deepfence-blue.svg?logo=slack">](https://join.slack.com/t/deepfence-community/shared_invite/zt-podmzle9-5X~qYx8wMaLt9bGWwkSdgQ) Got a question, need some help? Find the Deepfence team on Slack
9773
* [![GitHub issues](https://img.shields.io/github/issues/deepfence/SecretScanner)](https://github.com/deepfence/SecretScanner/issues) Got a feature request or found a bug? Raise an issue
9874
* [productsecurity *at* deepfence *dot* io](SECURITY.md): Found a security issue? Share it in confidence
99-
* Find out more at [deepfence.io](https://deepfence.io/)
10075

10176
## Security and Support
10277

agent-plugins-grpc

cmd/convert-rules/main.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package main
2+
3+
import (
4+
"encoding/json"
5+
"fmt"
6+
"os"
7+
8+
"github.com/deepfence/YaraHunter/pkg/threatintel"
9+
)
10+
11+
func main() {
12+
if len(os.Args) != 3 {
13+
fmt.Println("Usage: convert-rules <input.json> <output.yar>")
14+
os.Exit(1)
15+
}
16+
17+
inputFile := os.Args[1]
18+
outputFile := os.Args[2]
19+
20+
data, err := os.ReadFile(inputFile)
21+
if err != nil {
22+
fmt.Printf("Error reading file: %v\n", err)
23+
os.Exit(1)
24+
}
25+
26+
var fb threatintel.FeedsBundle
27+
if err := json.Unmarshal(data, &fb); err != nil {
28+
fmt.Printf("Error parsing JSON: %v\n", err)
29+
os.Exit(1)
30+
}
31+
32+
if err := threatintel.ExportYaraRules(outputFile, fb.ScannerFeeds.SecretRules, fb.Extra); err != nil {
33+
fmt.Printf("Error exporting rules: %v\n", err)
34+
os.Exit(1)
35+
}
36+
37+
fmt.Printf("Successfully converted %d rules to %s\n", len(fb.ScannerFeeds.SecretRules), outputFile)
38+
}

core/config_test.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ import (
1111

1212
func Test_ConfigMerge(t *testing.T) {
1313
config := &core.Config{
14-
BlacklistedStrings: []string{"base"},
15-
BlacklistedExtensions: []string{"base"},
16-
BlacklistedPaths: []string{"base"},
17-
BlacklistedEntropyExtensions: []string{"base"},
1814
Signatures: []core.ConfigSignature{
1915
{
2016
Name: "base",
@@ -42,10 +38,6 @@ func Test_ConfigMerge(t *testing.T) {
4238
}
4339

4440
config.Merge(&core.Config{
45-
BlacklistedStrings: []string{"merge"},
46-
BlacklistedExtensions: []string{"merge", "base"},
47-
BlacklistedPaths: []string{"base", "merge"},
48-
BlacklistedEntropyExtensions: []string{"base"},
4941
Signatures: []core.ConfigSignature{
5042
{
5143
Name: "merge",
@@ -73,10 +65,6 @@ func Test_ConfigMerge(t *testing.T) {
7365
})
7466

7567
expected := &core.Config{
76-
BlacklistedStrings: []string{"base", "merge"},
77-
BlacklistedExtensions: []string{"base", "merge"},
78-
BlacklistedPaths: []string{"base", "merge"},
79-
BlacklistedEntropyExtensions: []string{"base"},
8068
Signatures: []core.ConfigSignature{
8169
{
8270
Name: "base",

core/match.go

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"os"
55
"path/filepath"
66

7-
log "github.com/sirupsen/logrus"
7+
"github.com/rs/zerolog/log"
88
)
99

1010
type MatchFile struct {
@@ -19,43 +19,22 @@ func NewMatchFile(path string) MatchFile {
1919
path = filepath.ToSlash(path)
2020
_, filename := filepath.Split(path)
2121
extension := filepath.Ext(path)
22-
// contents, _ := ioutil.ReadFile(path)
2322

2423
return MatchFile{
2524
Path: path,
2625
Filename: filename,
2726
Extension: extension,
28-
Contents: []byte(""), // contents,
27+
Contents: []byte(""),
2928
}
3029
}
3130

32-
//// GetMatchingFiles Return the list of all applicable files inside the given directory for scanning
33-
// func GetMatchingFiles(dir string, baseDir string) (*bytes.Buffer, *bytes.Buffer, error) {
34-
// findCmd := "find " + dir
35-
// for _, skippableExt := range session.Config.BlacklistedExtensions {
36-
// findCmd += " -not -name \"*" + skippableExt + "\""
37-
// }
38-
// hostMountPath := *session.Options.HostMountPath
39-
// if hostMountPath != "" {
40-
// baseDir = hostMountPath
41-
// }
42-
// for _, skippablePathIndicator := range session.Config.BlacklistedPaths {
43-
// findCmd += " -path " + baseDir + skippablePathIndicator + " -prune -o"
44-
// }
45-
// maxFileSize := strconv.FormatUint(uint64(*session.Options.MaximumFileSize), 10)
46-
// findCmd += " -type f -size " + maxFileSize + "M"
47-
// log.Info("find command: %s", findCmd)
48-
//
49-
// return ExecuteCommand(findCmd)
50-
//}
51-
5231
// UpdateDirsPermissionsRW Update permissions for dirs in container images, so that they can be properly deleted
5332
func UpdateDirsPermissionsRW(dir string) {
5433
_ = filepath.WalkDir(dir, func(path string, f os.DirEntry, err error) error {
5534
if f.IsDir() {
5635
err := os.Chmod(path, 0700)
5736
if err != nil {
58-
log.Errorf("Failed to change dir %s permission: %s", path, err)
37+
log.Error().Err(err).Str("path", path).Msg("Failed to change dir permission")
5938
}
6039
}
6140
return nil

0 commit comments

Comments
 (0)