Skip to content

Commit

Permalink
添加从API读取多个目标支持字段
Browse files Browse the repository at this point in the history
  • Loading branch information
cn-kali-team committed Aug 21, 2023
1 parent 1c45b0a commit 28a3a02
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/post-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,23 @@ jobs:
sudo apt-get update
sudo apt-get install -y --no-install-recommends xz-utils liblz4-tool libssl-dev musl-tools pkg-config
sed -i -e "s/^version = .*/version = \"`date +'%-Y.%-m.%-d'`\"/" Cargo.toml
sed -i -e "s/\"observer_ward\"/\"observer_ward v`date +'%-Y.%-m.%-d'`\"/" src/cli.rs
- name: Install packages (Windows)
if: matrix.os == 'windows-latest'
shell: bash
run: |
choco install llvm openssl
export CARGO_PKG_VERSION=`date +'%-Y.%-m.%-d'`
sed -i -e "s/^version = .*/version = \"`date +'%-Y.%-m.%-d'`\"/" Cargo.toml
sed -i -e "s/\"observer_ward\"/\"observer_ward v`date +'%-Y.%-m.%-d'`\"/" src/cli.rs
echo "CARGO_PKG_VERSION=`date +'%Y.%m.%d'`" >>$GITHUB_ENV
echo "OPENSSL_DIR=C:\Program Files\OpenSSL-Win64" >>$GITHUB_ENV
echo "RUSTFLAGS=-C target-feature=+crt-static" >>$GITHUB_ENV
- name: Install packages (Macos)
if: matrix.os == 'macos-latest'
run: |
sed -i -e "s/^version = .*/version = \"`date +'%-Y.%-m.%-d'`\"/" Cargo.toml
sed -i -e "s/\"observer_ward\"/\"observer_ward v`date +'%-Y.%-m.%-d'`\"/" src/cli.rs
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

- 修复webhook判断
- 添加`webhook_auth`字段用来标识任务,还可以作为webhook的认证
- 添加从API读取多个目标支持`targets`字段

## [2023.8.14] - 2023.8.14

Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,16 @@ curl --request POST \
- 现在你可以在你的webhook服务器中读取请求头中的`Authorization`字段就可以得到他的值为`ID`
- 一次API请求中添加多个目标:`targets`,会自动和`target`字段合并去重
```bash
~ curl --request POST \
--url http://127.0.0.1:8000/v1/observer_ward \
--header 'Authorization: Bearer 22e038328151a7a06fd4ebfa63a10228' \
--header 'Content-Type: application/json' \
--data '{"target":"https://127.0.0.1:9443/","webhook_auth":"ID","targets":["https://127.0.0.1:8000/","http://127.0.0.1:9200/"]}'
```
### 危险模式
- `--danger`参数会加上敏感请求头,有可能会被Web防火墙拦截,默认不加。
Expand Down
3 changes: 2 additions & 1 deletion src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ async fn what_web_api(
return HttpResponse::Unauthorized().finish();
}
let mut targets = HashSet::new();
let config = config.0;
targets.insert(config.target.clone().unwrap_or_default());
targets.extend(config.targets);
let mut observer_ward = observer_ward_ins.read().await.clone();
let config = config.0;
observer_ward.config.webhook_auth = config.webhook_auth;
if observer_ward.config.webhook.is_none() {
let vec_results = observer_ward.scan(targets).await;
Expand Down
6 changes: 4 additions & 2 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ use std::process::{Command, Stdio};
#[derive(Debug, Serialize, Deserialize, Clone, FromArgs, Default)]
#[argh(description = "observer_ward")]
pub struct ObserverWardConfig {
// #[serde(default)]
// pub targets: Vec<String>,
/// multiple targets from the API
#[argh(option)]
#[serde(default)]
pub targets: Vec<String>,
/// the target (required, unless --stdin used)
#[argh(option, short = 't')]
pub target: Option<String>,
Expand Down

0 comments on commit 28a3a02

Please sign in to comment.