Skip to content

Commit 1f5bf8b

Browse files
M09Icclaude
andcommitted
feat: integrate Proton regex engine via proton-hae SDK
- RegularMatcher: proton engine as primary, Java regex as fallback - initProtonEngine: loads native via JNA, converts rules to JSON - matchWithProton: delegates to ProtonHaEEngine.match() with scope routing - Falls back to Java NFA/DFA if proton native is unavailable - build.gradle: add JNA + proton-hae SDK (libs/) + native bundling (natives/) - CI: download proton natives + SDK from chainreactors/proton releases Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 8a50ef4 commit 1f5bf8b

3 files changed

Lines changed: 259 additions & 282 deletions

File tree

‎.github/workflows/build.yml‎

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Build HaE with Proton
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
11+
defaults:
12+
run:
13+
working-directory: src/HaENet/sources
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- uses: actions/setup-java@v4
22+
with:
23+
java-version: '17'
24+
distribution: 'temurin'
25+
26+
- uses: gradle/actions/setup-gradle@v4
27+
28+
- name: Download proton natives
29+
env:
30+
GH_TOKEN: ${{ github.token }}
31+
run: |
32+
gh release download --repo chainreactors/proton --pattern 'proton-natives.tar.gz' --dir /tmp
33+
mkdir -p natives
34+
tar xzf /tmp/proton-natives.tar.gz -C natives/
35+
ls -lhR natives/
36+
37+
- name: Download proton-hae SDK
38+
env:
39+
GH_TOKEN: ${{ github.token }}
40+
run: |
41+
mkdir -p libs
42+
# Get the latest HaE SDK release JAR (standalone, no natives bundled)
43+
LATEST_TAG=$(gh release list --repo chainreactors/proton --limit 10 --json tagName --jq '[.[] | select(.tagName | startswith("hae-"))][0].tagName')
44+
if [ -n "$LATEST_TAG" ]; then
45+
VERSION=$(echo $LATEST_TAG | sed 's/hae-v\([^-]*\)-.*/\1/')
46+
gh release download "$LATEST_TAG" --repo chainreactors/proton --pattern "proton-hae-${VERSION}.jar" --dir libs/ || true
47+
fi
48+
# Fallback: build SDK from proton source
49+
if [ ! -f libs/proton-hae-*.jar ]; then
50+
echo "SDK JAR not found in releases, building from source..."
51+
cd ${{ github.workspace }}
52+
git clone --depth 1 https://github.com/chainreactors/proton /tmp/proton
53+
cd /tmp/proton/sdk/java/proton-hae
54+
mvn package -q
55+
cp target/proton-hae-*.jar ${{ github.workspace }}/src/HaENet/sources/libs/
56+
fi
57+
ls -lh libs/
58+
59+
- name: Build
60+
run: gradle jar
61+
62+
- name: Upload JAR
63+
uses: actions/upload-artifact@v4
64+
with:
65+
name: HaE-proton
66+
path: src/HaENet/sources/build/libs/*.jar
67+
68+
- name: Release
69+
if: github.ref == 'refs/heads/main'
70+
env:
71+
GH_TOKEN: ${{ github.token }}
72+
run: |
73+
JAR=$(ls build/libs/*.jar | head -1)
74+
TAG="v$(date +%Y%m%d)-$(echo ${{ github.sha }} | cut -c1-7)"
75+
gh release create "$TAG" \
76+
--title "HaE with Proton Engine $TAG" \
77+
--notes "HaE Burp extension with Proton regex engine" \
78+
"$JAR"

‎src/HaENet/sources/build.gradle‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ dependencies {
2323
implementation 'dk.brics.automaton:automaton:1.11-8'
2424
implementation 'com.github.ben-manes.caffeine:caffeine:3.1.8'
2525
implementation 'com.google.code.gson:gson:2.11.0'
26+
implementation 'net.java.dev.jna:jna:5.16.0'
27+
implementation fileTree(dir: 'libs', include: ['*.jar'])
2628
}
2729

2830
test {
@@ -35,4 +37,9 @@ jar {
3537
from {
3638
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
3739
}
40+
41+
// Bundle platform-specific native libraries for JNA auto-extraction
42+
from('natives') {
43+
into '.'
44+
}
3845
}

0 commit comments

Comments
 (0)