Skip to content

Commit

Permalink
Bump to golang 1.23 (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramanan-ravi authored Nov 5, 2024
1 parent f55d781 commit c856e00
Show file tree
Hide file tree
Showing 15 changed files with 192 additions and 140 deletions.
14 changes: 7 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.22-bookworm AS skopeo-builder
FROM golang:1.23-bookworm AS skopeo-builder

# Ubuntu (`libbtrfs-dev` requires Ubuntu 18.10 and above):
RUN apt update && DEBIAN_FRONTEND=noninteractive apt install -y libgpgme-dev libassuan-dev libbtrfs-dev libdevmapper-dev pkg-config
Expand All @@ -8,7 +8,7 @@ RUN cd $GOPATH/src/github.com/containers/skopeo && DISABLE_DOCS=1 make bin/skope
RUN cd $GOPATH/src/github.com/containers/skopeo && DISABLE_DOCS=1 make
RUN cd $GOPATH/src/github.com/containers/skopeo && cp ./bin/skopeo /usr/bin/skopeo

FROM golang:1.22-alpine3.18 AS builder
FROM golang:1.23-alpine3.20 AS builder

RUN apk add --no-cache \
git \
Expand Down Expand Up @@ -40,9 +40,9 @@ RUN apk add --no-cache -t .build-deps py-setuptools \
libmagic-static \
linux-headers

RUN cd /root && wget https://github.com/VirusTotal/yara/archive/refs/tags/v4.3.2.tar.gz \
&& tar -zxf v4.3.2.tar.gz \
&& cd yara-4.3.2 \
RUN cd /root && wget https://github.com/VirusTotal/yara/archive/refs/tags/v4.5.2.tar.gz \
&& tar -zxf v4.5.2.tar.gz \
&& cd yara-4.5.2 \
&& ./bootstrap.sh \
&& ./configure --prefix=/usr/local/yara --disable-dotnet --enable-magic --enable-cuckoo --disable-shared --enable-static\
&& make \
Expand All @@ -62,15 +62,15 @@ LABEL deepfence.role=system
COPY --from=skopeo-builder /usr/bin/skopeo /usr/bin/skopeo

ENV LD_LIBRARY_PATH=/usr/local/yara/lib \
DOCKERVERSION=24.0.6
DOCKERVERSION=27.3.1

RUN apt-get update && apt-get -qq -y --no-install-recommends install libjansson4 libssl3 libmagic1 libstdc++6 jq bash curl ca-certificates

ARG TARGETARCH

RUN <<EOF
set -eux
nerdctl_version=1.6.0
nerdctl_version=1.7.7
curl -fsSLOk https://github.com/containerd/nerdctl/releases/download/v${nerdctl_version}/nerdctl-${nerdctl_version}-linux-${TARGETARCH}.tar.gz
tar Cxzvvf /usr/local/bin nerdctl-${nerdctl_version}-linux-${TARGETARCH}.tar.gz
rm nerdctl-${nerdctl_version}-linux-${TARGETARCH}.tar.gz
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export IMAGE_REPOSITORY?=quay.io/deepfenceio
export DF_IMG_TAG?=3.0.0
export DF_IMG_TAG?=2.5.0

all: yarahunter

Expand Down
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,23 @@ Images may be compromised with the installation of a cryptominer such as XMRig.
Pull the official **yarahunter** image:

```
docker pull quay.io/deepfenceio/deepfence_malware_scanner_ce:2.3.0
docker pull quay.io/deepfenceio/deepfence_malware_scanner_ce:2.5.0
```

or Build it from source clone this repo and run below command
```
make docker
```

### Generate License Key

Run this command to generate a license key. Work/official email id has to be used.
```shell
curl https://license.deepfence.io/threatmapper/generate-license?first_name=<FIRST_NAME>&last_name=<LAST_NAME>&email=<EMAIL>&company=<ORGANIZATION_NAME>&resend_email=true
```

### Scan

Pull the image that needs to be scanned for example `metal3d/xmrig` and scan it:

```
Expand All @@ -59,7 +68,7 @@ docker run -i --rm --name=deepfence-yarahunter \
-e DEEPFENCE_LICENSE=<ThreatMapper or ThreatStryker license key> \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /tmp:/home/deepfence/output \
quay.io/deepfenceio/deepfence_malware_scanner_ce:3.0.0 \
quay.io/deepfenceio/deepfence_malware_scanner_ce:2.5.0 \
--image-name metal3d/xmrig:latest \
--output=json > xmrig-scan.json
```
Expand All @@ -74,7 +83,7 @@ docker run -i --rm --name=deepfence-yarahunter \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /tmp:/home/deepfence/output \
-v /tmp/rules:/tmp/rules \
quay.io/deepfenceio/deepfence_malware_scanner_ce:3.0.0 \
quay.io/deepfenceio/deepfence_malware_scanner_ce:2.5.0 \
--image-name metal3d/xmrig:latest \
--output=json \
--rules-path=/tmp/rules > xmrig-scan.json
Expand Down
2 changes: 1 addition & 1 deletion agent-plugins-grpc
Submodule agent-plugins-grpc updated 2 files
+7 −8 go.mod
+14 −20 go.sum
4 changes: 2 additions & 2 deletions docs/docs/yarahunter/configure/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ title: Command-Line Options
Display the command line options:

```bash
$ docker run -it --rm quay.io/deepfenceio/deepfence_malware_scanner_ce:2.3.0 --help
$ docker run -it --rm quay.io/deepfenceio/deepfence_malware_scanner_ce:2.5.0 --help
```

Note that all files and directories used in YaraHunter configuration are local to the container, not the host filesystem. The examples given illustrate how to map host directories to the container when needed.

### General Configuration

* `--log-level string`: one of FATAL, ERROR, IMPORTANT, WARN, INFO, DEBUG (default "ERROR"); print messages of this severity or higher.
* `--debug-level string`: one of FATAL, ERROR, IMPORTANT, WARN, INFO, DEBUG (default "ERROR"); print messages of this severity or higher.
* `--threads int`: Number of concurrent threads to use during scan (default number of logical CPUs).
* `--temp-directory string`: temporary storage for working data (default "/tmp")

Expand Down
6 changes: 4 additions & 2 deletions docs/docs/yarahunter/configure/output.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ title: Configure Output

# Configure Output

YaraHunter can writes output to `stdout` it can redirected to a file for further analysis.
YaraHunter can writes output to `stdout`. It can be redirected to a file for further analysis.

```bash
docker run -i --rm --name=yara-hunter \
-e DEEPFENCE_PRODUCT=<ThreatMapper or ThreatStryker> \
-e DEEPFENCE_LICENSE=<ThreatMapper or ThreatStryker license key> \
-v /var/run/docker.sock:/var/run/docker.sock \
quay.io/deepfenceio/deepfence_malware_scanner_ce:2.3.0 \
quay.io/deepfenceio/deepfence_malware_scanner_ce:2.5.0 \
--image-name node:latest \
# highlight-next-line
--output=json > xmrig-scan.json
Expand Down
4 changes: 3 additions & 1 deletion docs/docs/yarahunter/configure/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ You can mount the rules directory over the existing one (using `-v $(pwd)/my-rul
mkdir ./my-rules

docker run -it --rm --name=yara-hunter \
-e DEEPFENCE_PRODUCT=<ThreatMapper or ThreatStryker> \
-e DEEPFENCE_LICENSE=<ThreatMapper or ThreatStryker license key> \
-v /var/run/docker.sock:/var/run/docker.sock \
# highlight-next-line
-v $(pwd)/my-rules:/tmp/my-rules \
quay.io/deepfenceio/deepfence_malware_scanner_ce:2.3.0 --image-name node:latest \
quay.io/deepfenceio/deepfence_malware_scanner_ce:2.5.0 --image-name node:latest \
# highlight-next-line
--rules-path /tmp/my-rules
```
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/yarahunter/img/yarahunter.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 23 additions & 1 deletion docs/docs/yarahunter/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ Key capabilities:

![Yadare in Action](img/yarahunter.svg)

## Generate License Key

Run this command to generate a license key. Work/official email id has to be used.
```shell
curl https://license.deepfence.io/threatmapper/generate-license?first_name=<FIRST_NAME>&last_name=<LAST_NAME>&email=<EMAIL>&company=<ORGANIZATION_NAME>&resend_email=true
```

## Example: Finding Indicators of Compromise in a Container Image

Expand All @@ -27,9 +33,11 @@ Images may be compromised with the installation of a cryptominer such as XMRig.
docker pull metal3d/xmrig

docker run -i --rm --name=deepfence-yarahunter \
-e DEEPFENCE_PRODUCT=<ThreatMapper or ThreatStryker> \
-e DEEPFENCE_LICENSE=<ThreatMapper or ThreatStryker license key> \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /tmp:/home/deepfence/output \
quay.io/deepfenceio/deepfence_malware_scanner_ce:2.3.0 \
quay.io/deepfenceio/deepfence_malware_scanner_ce:2.5.0 \
--image-name metal3d/xmrig:latest \
--output=json > xmrig-scan.json
```
Expand All @@ -43,6 +51,20 @@ cat /tmp/xmrig-scan.json | jq '.IOC[] | ."Matched Rule Name"'

This returns a list of the IOCs identified in the container we scanned.

Rules can also be cached to use next run by mounting a seperate path and passing `rules-path` argument
```bash
docker run -i --rm --name=deepfence-yarahunter \
-e DEEPFENCE_PRODUCT=<ThreatMapper or ThreatStryker> \
-e DEEPFENCE_LICENSE=<ThreatMapper or ThreatStryker license key> \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /tmp:/home/deepfence/output \
-v /tmp/rules:/tmp/rules \
quay.io/deepfenceio/deepfence_malware_scanner_ce:2.5.0 \
--image-name metal3d/xmrig:latest \
--output=json \
--rules-path=/tmp/rules > xmrig-scan.json
```

## When to use YaraHunter

YaraHunter can be used in the following ways:
Expand Down
17 changes: 14 additions & 3 deletions docs/docs/yarahunter/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@ Pull the latest YaraHunter image, and use it to scan a `node:latest` container.
## Pull the latest YaraHunter image

```bash
docker pull quay.io/deepfenceio/deepfence_malware_scanner_ce:2.3.0
docker pull quay.io/deepfenceio/deepfence_malware_scanner_ce:2.5.0
```

## Generate License Key

Run this command to generate a license key. Work/official email id has to be used.
```shell
curl https://license.deepfence.io/threatmapper/generate-license?first_name=<FIRST_NAME>&last_name=<LAST_NAME>&email=<EMAIL>&company=<ORGANIZATION_NAME>&resend_email=true
```

## Scan a Container Image
Expand All @@ -20,8 +27,10 @@ Pull an image to your local repository, then scan it
docker pull node:latest

docker run -i --rm --name=yara-hunter \
-e DEEPFENCE_PRODUCT=<ThreatMapper or ThreatStryker> \
-e DEEPFENCE_LICENSE=<ThreatMapper or ThreatStryker license key> \
-v /var/run/docker.sock:/var/run/docker.sock \
quay.io/deepfenceio/deepfence_malware_scanner_ce:2.3.0 \
quay.io/deepfenceio/deepfence_malware_scanner_ce:2.5.0 \
--image-name node:latest

docker rmi node:latest
Expand All @@ -33,9 +42,11 @@ You can summarise the results by processing the JSON output, e.g. using `jq`:

```bash
docker run -i --rm --name=yara-hunter \
-e DEEPFENCE_PRODUCT=<ThreatMapper or ThreatStryker> \
-e DEEPFENCE_LICENSE=<ThreatMapper or ThreatStryker license key> \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /tmp:/home/deepfence/output \
quay.io/deepfenceio/deepfence_malware_scanner_ce:2.3.0 \
quay.io/deepfenceio/deepfence_malware_scanner_ce:2.5.0 \
--image-name node:latest \
--output=json > node-latest.json

Expand Down
6 changes: 3 additions & 3 deletions docs/docs/yarahunter/using/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ title: Build YaraHunter
YaraHunter is a self-contained docker-based tool. Clone the [YaraHunter repository](https://github.com/deepfence/YaraHunter), then build:

```bash
docker build --rm=true --tag=quay.io/deepfenceio/deepfence_malware_scanner_ce:2.3.0 -f Dockerfile .
docker build --rm=true --tag=quay.io/deepfenceio/deepfence_malware_scanner_ce:2.5.0 -f Dockerfile .
```

Alternatively, you can pull the official deepfence image at `quay.io/deepfenceio/deepfence_malware_scanner_ce:2.3.0`.
Alternatively, you can pull the official deepfence image at `quay.io/deepfenceio/deepfence_malware_scanner_ce:2.5.0`.

```bash
docker pull quay.io/deepfenceio/deepfence_malware_scanner_ce:2.3.0
docker pull quay.io/deepfenceio/deepfence_malware_scanner_ce:2.5.0
```
2 changes: 1 addition & 1 deletion docs/docs/yarahunter/using/grpc.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ docker run -it --rm --name=deepfence-malwarescanner \
-v $(pwd):/home/deepfence/output \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /tmp/sock:/tmp/sock \
quay.io/deepfenceio/deepfence_malware_scanner_ce:2.3.0 \
quay.io/deepfenceio/deepfence_malware_scanner_ce:2.5.0 \
-socket-path /tmp/sock/s.sock
```

Expand Down
12 changes: 9 additions & 3 deletions docs/docs/yarahunter/using/scan.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ Pull the image to your local repository, then scan it
docker pull node:latest

docker run -it --rm --name=yara-hunter \
-e DEEPFENCE_PRODUCT=<ThreatMapper or ThreatStryker> \
-e DEEPFENCE_LICENSE=<ThreatMapper or ThreatStryker license key> \
-v /var/run/docker.sock:/var/run/docker.sock \
quay.io/deepfenceio/deepfence_malware_scanner_ce:2.3.0 \
quay.io/deepfenceio/deepfence_malware_scanner_ce:2.5.0 \
# highlight-next-line
--image-name node:latest

Expand All @@ -29,10 +31,12 @@ Mount the root directory into the YaraHunter container at a location of your cho

```bash
docker run -it --rm --name=yara-hunter \
-e DEEPFENCE_PRODUCT=<ThreatMapper or ThreatStryker> \
-e DEEPFENCE_LICENSE=<ThreatMapper or ThreatStryker license key> \
-v /var/run/docker.sock:/var/run/docker.sock \
# highlight-next-line
-v /:/deepfence/mnt \
quay.io/deepfenceio/deepfence_malware_scanner_ce:2.3.0 \
quay.io/deepfenceio/deepfence_malware_scanner_ce:2.5.0 \
# highlight-next-line
--host-mount-path /deepfence/mnt --container-id 69221b948a73
```
Expand All @@ -43,9 +47,11 @@ Mount the filesystem within the YaraHunter container and scan it:

```bash
docker run -it --rm --name=yara-hunter \
-e DEEPFENCE_PRODUCT=<ThreatMapper or ThreatStryker> \
-e DEEPFENCE_LICENSE=<ThreatMapper or ThreatStryker license key> \
# highlight-next-line
-v ~/src/YARA-RULES:/tmp/YARA-RULES \
quay.io/deepfenceio/deepfence_malware_scanner_ce:2.3.0 \
quay.io/deepfenceio/deepfence_malware_scanner_ce:2.5.0 \
# highlight-next-line
--local /tmp/YARA-RULES --host-mount-path /tmp/YARA-RULES
```
Expand Down
Loading

0 comments on commit c856e00

Please sign in to comment.