Skip to content

Commit

Permalink
Add yara and r2yara
Browse files Browse the repository at this point in the history
  • Loading branch information
prodrigestivill committed Apr 16, 2024
1 parent 3e47002 commit becc3ff
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 4 deletions.
7 changes: 6 additions & 1 deletion .github/scripts/update-versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ cd "$(dirname "$0")/../.."

getLatestReleaseTag() {
echo "Checking latest release version for $1..." > /dev/stderr
gh release view --repo "$1" --json tagName --template '{{.tagName}}'
V=$(gh release view --repo "$1" --json tagName --template '{{.tagName}}')
if [ -n "$2" ]; then V="${V#$2}"; fi
if [ -n "$3" ]; then V="${V%$3}"; fi
echo "$V"
}

cat << EOF > versions.mk
R2_VERSION=$(getLatestReleaseTag radareorg/radare2)
R2GHIDRA_VERSION=$(getLatestReleaseTag radareorg/r2ghidra)
R2FRIDA_VERSION=$(getLatestReleaseTag nowsecure/r2frida)
R2DEC_VERSION=$(getLatestReleaseTag wargio/r2dec-js)
YARA_VERSION=$(getLatestReleaseTag VirusTotal/yara v)
R2YARA_VERSION=$(getLatestReleaseTag radareorg/r2yara)
EOF
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ DOCKER_BUILD_ARGS+= \
--build-arg R2_VERSION=$(R2_VERSION) \
--build-arg R2GHIDRA_VERSION=$(R2GHIDRA_VERSION) \
--build-arg R2FRIDA_VERSION=$(R2FRIDA_VERSION) \
--build-arg R2DEC_VERSION=$(R2DEC_VERSION)
--build-arg R2DEC_VERSION=$(R2DEC_VERSION) \
--build-arg YARA_VERSION=$(YARA_VERSION) \
--build-arg R2YARA_VERSION=$(R2YARA_VERSION)

.PHONY: all snap docker update clean \
buildx snap-buildx docker-buildx docker-buildx-tarball \
Expand Down
1 change: 1 addition & 0 deletions README-containers.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The resulting build includes the following projects:
* [r2ghidra](https://github.com/radareorg/r2ghidra)
* [r2frida](https://github.com/nowsecure/r2frida) (only in supported platforms)
* [r2dec](https://github.com/wargio/r2dec-js)
* [r2yara](https://github.com/radareorg/r2yara)
* [r2pipe](https://pypi.org/project/r2pipe/) (for Python)


Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The resulting build includes the following projects:
* [r2ghidra](https://github.com/radareorg/r2ghidra)
* [r2frida](https://github.com/nowsecure/r2frida) (only in supported platforms)
* [r2dec](https://github.com/wargio/r2dec-js)
* [r2yara](https://github.com/radareorg/r2yara)

## Install the snap

Expand Down
30 changes: 28 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ RUN apt-get update && \
python3-venv \
ninja-build \
gettext-base \
autoconf \
automake \
bison \
flex \
libtool \
libssl-dev \
&& \
rm -rf /var/lib/apt/lists/* && \
python3 -m venv /opt/meson && /opt/meson/bin/pip3 install "meson~=${MESON_VERSION}" && \
Expand Down Expand Up @@ -68,11 +74,26 @@ RUN git clone --branch "$R2DEC_VERSION" --recurse-submodules --depth 1 https://g
meson setup --prefix "$PREFIX" build && \
ninja -C build install

# Build yara
ARG YARA_VERSION
RUN git clone --branch "v$YARA_VERSION" --recurse-submodules --depth 1 https://github.com/VirusTotal/yara.git && \
cd yara && \
./bootstrap.sh && \
./configure --prefix="$PREFIX" && \
make && make install

# Build r2yara
ARG R2YARA_VERSION
RUN git clone --branch "$R2YARA_VERSION" --recurse-submodules --depth 1 https://github.com/radareorg/r2yara.git && \
cd r2yara && \
./configure --prefix="$PREFIX" --with-checks-level=0 && \
make && make install

# Generate SBOM files
ARG R2_SNAP_COMMIT
COPY sbom /usr/src/sbom
RUN mkdir -p "$PREFIX/share/sbom/"; \
SBOMS="radare2-snap radare2 r2ghidra r2dec"; \
SBOMS="radare2-snap radare2 r2ghidra r2dec yara r2yara"; \
[ -n "$FRIDA_ARCH" ] && SBOMS="$SBOMS r2frida"; \
for c in $SBOMS; do \
echo "Generate SBOM for $c..."; \
Expand Down Expand Up @@ -133,7 +154,12 @@ ARG BUILDKIT_SBOM_SCAN_STAGE=true

# Create non-root user
RUN apt-get update && \
apt-get install -y --no-install-recommends sudo python3-pip python3-setuptools && \
apt-get install -y --no-install-recommends \
sudo \
openssl \
python3-pip \
python3-setuptools \
&& \
rm -rf /var/lib/apt/lists/* && \
mkdir -p /var/snap/radare2/current /var/snap/radare2/common && \
useradd -m r2 && \
Expand Down
33 changes: 33 additions & 0 deletions docker/sbom/r2yara.spdx.json.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"SPDXID": "SPDXRef-DOCUMENT",
"spdxVersion": "SPDX-2.3",
"creationInfo": {
"created": "2024-03-07T14:00:00Z",
"creators": [ "Organization: radare org" ]
},
"name": "r2yara",
"dataLicense": "CC0-1.0",
"documentDescribes": [
"SPDXRef-com.github.radareorg-r2ghidra"
],
"documentNamespace": "https://github.com/radareorg/radare2-snap/sbom/r2yara-${R2_SNAP_COMMIT}",
"packages": [
{
"SPDXID": "SPDXRef-com.github.radareorg-r2yara",
"name": "r2yara",
"versionInfo": "${R2YARA_VERSION}",
"downloadLocation": "git+https://github.com/radareorg/r2yara#${R2YARA_VERSION}",
"filesAnalyzed": false,
"licenseDeclared": "LGPL-3.0-only",
"supplier": "Organization: radare org",
"primaryPackagePurpose": "LIBRARY",
"externalRefs": [
{
"referenceCategory": "PACKAGE-MANAGER",
"referenceType": "purl",
"referenceLocator": "pkg:github/radareorg/r2yara@${R2YARA_VERSION}"
}
]
}
]
}
33 changes: 33 additions & 0 deletions docker/sbom/yara.spdx.json.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"SPDXID": "SPDXRef-DOCUMENT",
"spdxVersion": "SPDX-2.3",
"creationInfo": {
"created": "2024-03-07T14:00:00Z",
"creators": [ "Organization: radare org" ]
},
"name": "yara",
"dataLicense": "CC0-1.0",
"documentDescribes": [
"SPDXRef-com.github.virustotal-yara"
],
"documentNamespace": "https://github.com/radareorg/radare2-snap/sbom/yara-${R2_SNAP_COMMIT}",
"packages": [
{
"SPDXID": "SPDXRef-com.github.virustotal-yara",
"name": "yara",
"versionInfo": "${YARA_VERSION}",
"downloadLocation": "git+https://github.com/VirusTotal/yara#${YARA_VERSION}",
"filesAnalyzed": false,
"licenseDeclared": "BSD-3-Clause",
"supplier": "Organization: VirusTotal",
"primaryPackagePurpose": "LIBRARY",
"externalRefs": [
{
"referenceCategory": "PACKAGE-MANAGER",
"referenceType": "purl",
"referenceLocator": "pkg:github/VirusTotal/yara@${YARA_VERSION}"
}
]
}
]
}
2 changes: 2 additions & 0 deletions versions.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ R2_VERSION=5.9.0
R2GHIDRA_VERSION=5.9.0
R2FRIDA_VERSION=5.9.0
R2DEC_VERSION=5.9.0
YARA_VERSION=4.5.0
R2YARA_VERSION=1.2.2

0 comments on commit becc3ff

Please sign in to comment.