Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ node_modules
*.vsix
.idea/
*/bin
target/
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ The extension will automatically find coverage reports in `trident-tests` and vi
## Requirements

- Visual Studio Code 1.96.0 or newer
- Rust and Cargo (latest stable) for Solana program security scanning
- Rust nightly toolchain (`nightly-2025-09-18`) for Solana program security scanning
- Install with: `rustup toolchain install nightly-2025-09-18`
- dylint-driver for running security detectors
- Install with: `cargo install cargo-dylint dylint-link`
- Trident tests in your workspace for code coverage features

## Getting Started
Expand Down
103 changes: 103 additions & 0 deletions build_all_lints.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#!/bin/bash

# Build all Dylint lints and copy them to the extension directory
# This script should be run before packaging the extension

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"

# Required nightly toolchain version
REQUIRED_NIGHTLY="nightly-2025-09-18"

echo "🔨 Building all Dylint lints with $REQUIRED_NIGHTLY..."
echo ""

# Check if required nightly is installed
if ! rustup toolchain list | grep -q "$REQUIRED_NIGHTLY"; then
echo "⚠️ Required Rust toolchain not found: $REQUIRED_NIGHTLY"
echo "📦 Installing $REQUIRED_NIGHTLY..."
rustup toolchain install "$REQUIRED_NIGHTLY"
echo "✅ Toolchain installed"
echo ""
fi

# Detect platform
OS=$(uname -s)
ARCH=$(uname -m)

if [ "$OS" = "Darwin" ]; then
if [ "$ARCH" = "arm64" ]; then
PLATFORM="macos-arm64"
LIB_EXT="dylib"
else
PLATFORM="macos-x64"
LIB_EXT="dylib"
fi
elif [ "$OS" = "Linux" ]; then
if [ "$ARCH" = "x86_64" ]; then
PLATFORM="linux-x64"
LIB_EXT="so"
elif [ "$ARCH" = "aarch64" ]; then
PLATFORM="linux-arm64"
LIB_EXT="so"
else
echo "❌ Unsupported architecture: $ARCH"
exit 1
fi
else
echo "❌ Unsupported OS: $OS"
exit 1
fi

echo "📦 Platform: $PLATFORM"
echo ""

# Create output directory
OUTPUT_DIR="$SCRIPT_DIR/lints_compiled/$PLATFORM"
mkdir -p "$OUTPUT_DIR"

# Find all detector directories
DETECTOR_DIRS=$(find "$SCRIPT_DIR/extension/detectors" -mindepth 1 -maxdepth 1 -type d 2>/dev/null || true)

if [ -z "$DETECTOR_DIRS" ]; then
echo "⚠️ No detector directories found in extension/detectors"
exit 1
fi

# Build each detector
for DETECTOR_DIR in $DETECTOR_DIRS; do
DETECTOR_NAME=$(basename "$DETECTOR_DIR")
echo "🔧 Building detector: $DETECTOR_NAME"

cd "$DETECTOR_DIR"

# Build in debug mode (faster for development)
# Use --release for production builds
# The rust-toolchain file in each detector directory will be used automatically
cargo build

# Find the built library
LIB_FILE=$(find target/debug -name "lib${DETECTOR_NAME}@*.$LIB_EXT" -o -name "lib${DETECTOR_NAME}.$LIB_EXT" | head -n 1)

if [ -z "$LIB_FILE" ]; then
echo "⚠️ Warning: Could not find library for $DETECTOR_NAME"
continue
fi

# Copy to output directory
cp "$LIB_FILE" "$OUTPUT_DIR/"
echo "✅ Copied $(basename "$LIB_FILE") to $OUTPUT_DIR"
echo ""
done

cd "$SCRIPT_DIR"

echo ""
echo "🎉 All detectors built successfully!"
echo ""
echo "📁 Compiled detectors are in: $OUTPUT_DIR"
ls -lh "$OUTPUT_DIR"
echo ""
echo "💡 To use these detectors, make sure they are included in the extension package."
4 changes: 4 additions & 0 deletions extension/.vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,7 @@ Thumbs.db
desktop.ini
*.zip
*.vsix

# Dylint detectors - exclude build artifacts but include source
detectors/**/target/**
detectors/**/Cargo.lock
6 changes: 6 additions & 0 deletions extension/detectors/unchecked_math/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[target.'cfg(all())']
rustflags = ["-C", "linker=dylint-link"]

# For Rust versions 1.74.0 and onward, the following alternative can be used
# (see https://github.com/rust-lang/cargo/pull/12535):
# linker = "dylint-link"
1 change: 1 addition & 0 deletions extension/detectors/unchecked_math/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
Loading
Loading