generated from devcontainers/feature-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
105 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"name": "Ghidra", | ||
"id": "ghidra", | ||
"version": "1.0.0", | ||
"description": "A feature that installs Ghidra", | ||
"keywords": ["ghidra", "reverse-engineering", "security"], | ||
"options": { | ||
"version_tag": { | ||
"type": "string", | ||
"proposals": [ | ||
"latest", | ||
"Ghidra_11.1.1_build" | ||
], | ||
"default": "latest", | ||
"description": "Select the Ghidra version (either 'latest' or a GitHub release tag)" | ||
}, | ||
|
||
"repository": { | ||
"type": "string", | ||
"proposals": [ | ||
"NationalSecurityAgency/ghidra" | ||
], | ||
"default": "NationalSecurityAgency/ghidra", | ||
"description": "Define the repository to grab" | ||
} | ||
}, | ||
|
||
"installsAfter": [ | ||
"ghcr.io/devcontainers/features/common-utils" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env bash | ||
|
||
echo "Activating feature 'ghidra'" | ||
|
||
set -euo pipefail | ||
|
||
REPOSITORY=${REPOSITORY:-NationalSecurityAgency/ghidra} | ||
VERSION_TAG=${VERSION_TAG:-latest} | ||
|
||
INSTALL_DIR=${INSTALL_DIR:-/opt/ghidra} | ||
|
||
# From aws-cli feature (https://github.com/devcontainers/features/blob/main/src/aws-cli/install.sh#L59-L72) | ||
export DEBIAN_FRONTEND=noninteractive | ||
check_packages() { | ||
if ! dpkg -s "$@" > /dev/null 2>&1; then | ||
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then | ||
echo "Running apt-get update..." | ||
apt-get update -y | ||
fi | ||
|
||
apt-get install -y --no-install-recommends "$@" | ||
fi | ||
} | ||
|
||
check_packages curl ca-certificates jq libarchive-tools | ||
|
||
if [ $VERSION_TAG = "latest" ]; then | ||
RELEASE_API_URL="https://api.github.com/repos/NationalSecurityAgency/ghidra/releases/latest" | ||
else | ||
RELEASE_API_URL="https://api.github.com/repos/NationalSecurityAgency/ghidra/releases/tags/$VERSION_TAG" | ||
fi | ||
|
||
ASSET_URL=$(curl "$RELEASE_API_URL" --silent --show-error | jq -r ".assets[0].browser_download_url") | ||
|
||
TMP=$(mktemp -d) | ||
DESTINATION_FILE="$TMP/ghidra.zip" | ||
|
||
echo "[ghidra] [+] Downloading version with tag $VERSION_TAG" | ||
|
||
curl --location --silent --show-error \ | ||
--output "$DESTINATION_FILE" \ | ||
"$ASSET_URL" | ||
|
||
mkdir -p "$INSTALL_DIR" | ||
|
||
echo "[ghidra] [+] Extracting to $INSTALL_DIR" | ||
|
||
# Extract the archive by stripping the first directory so that we don't end up with a subfolder (e.g ghidra_11.1.1_PUBLIC_20240614) in $INSTALL_DIR | ||
bsdtar --strip-components=1 -xf "$DESTINATION_FILE" -C "$INSTALL_DIR" | ||
|
||
rm -rf "$TMP" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
# Optional: Import test library bundled with the devcontainer CLI | ||
source dev-container-features-test-lib | ||
|
||
check "Ghidra folder exists" test -d /opt/ghidra | ||
|
||
# Report results | ||
# If any of the checks above exited with a non-zero exit code, the test will fail. | ||
reportResults |