Skip to content

Commit 25b085c

Browse files
authored
feat: ai敏感词拦截插件 (alibaba#1190)
1 parent dcea483 commit 25b085c

File tree

20 files changed

+66894
-162
lines changed

20 files changed

+66894
-162
lines changed

.github/workflows/build-and-test-plugin.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ jobs:
4949
with:
5050
go-version: 1.19
5151

52+
- name: Setup Rust
53+
uses: actions-rs/toolchain@v1
54+
with:
55+
toolchain: stable
56+
if: matrix.wasmPluginType == 'RUST'
5257
- name: Setup Golang Caches
5358
uses: actions/cache@v4
5459
with:

plugins/wasm-rust/Cargo.lock

Lines changed: 110 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/wasm-rust/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2021"
66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

88
[dependencies]
9-
proxy-wasm = "0.2.1"
9+
proxy-wasm = { git="https://github.com/higress-group/proxy-wasm-rust-sdk", branch="main", version="0.2.2" }
1010
serde = "1.0"
1111
serde_json = "1.0"
1212
uuid = { version = "1.3.3", features = ["v4"] }

plugins/wasm-rust/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
FROM rust:1.69 as builder
1+
FROM rust:1.80 as builder
22
WORKDIR /workspace
3+
RUN apt update && apt-get install gcc gcc-multilib llvm clang -y && apt clean
34
RUN rustup target add wasm32-wasi
45
ARG PLUGIN_NAME="say-hello"
56
ARG BUILD_OPTS="--release"
@@ -9,4 +10,4 @@ RUN cargo build --target wasm32-wasi $BUILD_OPTS \
910
&& cp target/wasm32-wasi/release/*.wasm /main.wasm
1011

1112
FROM scratch
12-
COPY --from=builder /main.wasm plugin.wasm
13+
COPY --from=builder /main.wasm plugin.wasm

plugins/wasm-rust/Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,17 @@ IMAGE_TAG = $(if $(strip $(PLUGIN_VERSION)),${PLUGIN_VERSION},${BUILD_TIME}-${CO
66
IMG ?= ${REGISTRY}${PLUGIN_NAME}:${IMAGE_TAG}
77

88
.DEFAULT:
9+
lint-base:
10+
cargo fmt --all --check
11+
cargo clippy --workspace --all-features --all-targets
12+
lint:
13+
cargo fmt --all --check --manifest-path extensions/${PLUGIN_NAME}/Cargo.toml
14+
cargo clippy --workspace --all-features --all-targets --manifest-path extensions/${PLUGIN_NAME}/Cargo.toml
915
build:
1016
DOCKER_BUILDKIT=1 docker build \
1117
--build-arg PLUGIN_NAME=${PLUGIN_NAME} \
1218
-t ${IMG} \
1319
--output extensions/${PLUGIN_NAME} \
1420
.
1521
@echo ""
16-
@echo "output wasm file: extensions/${PLUGIN_NAME}/plugin.wasm"
22+
@echo "output wasm file: extensions/${PLUGIN_NAME}/plugin.wasm"

0 commit comments

Comments
 (0)