Skip to content

Commit 4485d04

Browse files
authored
Merge pull request #4 from AElfProject/codex/wasm32-wasip2-alpha1
chore(repo): 🧾 prepare open source readiness baseline
2 parents 3bcfd49 + 54b97b6 commit 4485d04

File tree

13 files changed

+125
-3
lines changed

13 files changed

+125
-3
lines changed

.github/workflows/gitleaks.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: gitleaks
2+
3+
on:
4+
push:
5+
branches:
6+
- "**"
7+
pull_request:
8+
9+
jobs:
10+
gitleaks:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
- uses: gacts/gitleaks@v1
17+
with:
18+
config-path: .gitleaks.toml

.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,19 @@
11
/target
22
.DS_Store
3+
.env
4+
.env.*
5+
!.env.example
6+
.envrc
7+
.direnv/
8+
.npmrc
9+
.aws/
10+
.venv/
11+
venv/
12+
.cargo/credentials
13+
*.pem
14+
*.key
15+
*.p12
16+
*.crt
17+
*.cer
18+
*.secret
19+
*.secrets

.gitleaks.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
title = "aelf-web3.rust gitleaks config"
2+
3+
[allowlist]
4+
description = "Public readonly test key used by docs, examples, and smoke tests. Never fund it."
5+
regexes = [
6+
'''(?m)\b0000000000000000000000000000000000000000000000000000000000000001\b''',
7+
]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 AElf
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
9595

9696
## Raw Transaction
9797

98+
The sample private key below is a public test-only readonly key. Never fund it.
99+
98100
```rust
99101
use aelf_sdk::proto::token::TransferInput;
100102
use aelf_sdk::{AElfClient, ClientConfig, Wallet, decode_address};
@@ -103,6 +105,7 @@ use prost::Message;
103105
#[tokio::main]
104106
async fn main() -> Result<(), Box<dyn std::error::Error>> {
105107
let client = AElfClient::new(ClientConfig::new("http://127.0.0.1:8000"))?;
108+
// Public test-only readonly key. Never fund it.
106109
let wallet = Wallet::from_private_key(
107110
"0000000000000000000000000000000000000000000000000000000000000001",
108111
)?;
@@ -138,13 +141,16 @@ Public-node note:
138141

139142
## Typed Contracts
140143

144+
The sample private key below is a public test-only readonly key. Never fund it.
145+
141146
```rust
142147
use aelf_sdk::proto::token::GetBalanceInput;
143148
use aelf_sdk::{AElfClient, ClientConfig, Wallet, address_to_pb};
144149

145150
#[tokio::main]
146151
async fn main() -> Result<(), Box<dyn std::error::Error>> {
147152
let client = AElfClient::new(ClientConfig::new("http://127.0.0.1:8000"))?;
153+
// Public test-only readonly key. Never fund it.
148154
let wallet = Wallet::from_private_key(
149155
"0000000000000000000000000000000000000000000000000000000000000001",
150156
)?;
@@ -164,13 +170,16 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
164170

165171
## Dynamic Contracts
166172

173+
The sample private key below is a public test-only readonly key. Never fund it.
174+
167175
```rust
168176
use aelf_sdk::{AElfClient, ClientConfig, Wallet};
169177
use serde_json::json;
170178

171179
#[tokio::main]
172180
async fn main() -> Result<(), Box<dyn std::error::Error>> {
173181
let client = AElfClient::new(ClientConfig::new("http://127.0.0.1:8000"))?;
182+
// Public test-only readonly key. Never fund it.
174183
let wallet = Wallet::from_private_key(
175184
"0000000000000000000000000000000000000000000000000000000000000001",
176185
)?;
@@ -214,6 +223,8 @@ Useful environment variables:
214223
- `AELF_AMOUNT`
215224
- `AELF_SEND`
216225

226+
`public_balance` and `dynamic_contract_get_balance` fall back to a public test-only readonly key when `AELF_PRIVATE_KEY` is omitted. Never fund it.
227+
217228
## Feature Flags
218229

219230
v0.1 alpha exposes one transport feature:
@@ -430,6 +441,10 @@ MSRV:
430441
- The workspace MSRV is Rust `1.85`.
431442
- CI enforces it with `cargo +1.85.0 check --workspace --all-targets --all-features --locked`.
432443

444+
## Security
445+
446+
See [SECURITY.md](SECURITY.md) for private vulnerability disclosure instructions.
447+
433448
## License
434449

435450
MIT

README.zh.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
9595

9696
## Raw Transaction
9797

98+
下面示例里的私钥是公开的只读测试 key,绝对不要充值或承载资产。
99+
98100
```rust
99101
use aelf_sdk::proto::token::TransferInput;
100102
use aelf_sdk::{AElfClient, ClientConfig, Wallet, decode_address};
@@ -103,6 +105,7 @@ use prost::Message;
103105
#[tokio::main]
104106
async fn main() -> Result<(), Box<dyn std::error::Error>> {
105107
let client = AElfClient::new(ClientConfig::new("http://127.0.0.1:8000"))?;
108+
// 公开的只读测试 key,绝对不要充值或承载资产。
106109
let wallet = Wallet::from_private_key(
107110
"0000000000000000000000000000000000000000000000000000000000000001",
108111
)?;
@@ -138,13 +141,16 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
138141

139142
## Typed Contracts
140143

144+
下面示例里的私钥是公开的只读测试 key,绝对不要充值或承载资产。
145+
141146
```rust
142147
use aelf_sdk::proto::token::GetBalanceInput;
143148
use aelf_sdk::{AElfClient, ClientConfig, Wallet, address_to_pb};
144149

145150
#[tokio::main]
146151
async fn main() -> Result<(), Box<dyn std::error::Error>> {
147152
let client = AElfClient::new(ClientConfig::new("http://127.0.0.1:8000"))?;
153+
// 公开的只读测试 key,绝对不要充值或承载资产。
148154
let wallet = Wallet::from_private_key(
149155
"0000000000000000000000000000000000000000000000000000000000000001",
150156
)?;
@@ -164,13 +170,16 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
164170

165171
## Dynamic Contracts
166172

173+
下面示例里的私钥是公开的只读测试 key,绝对不要充值或承载资产。
174+
167175
```rust
168176
use aelf_sdk::{AElfClient, ClientConfig, Wallet};
169177
use serde_json::json;
170178

171179
#[tokio::main]
172180
async fn main() -> Result<(), Box<dyn std::error::Error>> {
173181
let client = AElfClient::new(ClientConfig::new("http://127.0.0.1:8000"))?;
182+
// 公开的只读测试 key,绝对不要充值或承载资产。
174183
let wallet = Wallet::from_private_key(
175184
"0000000000000000000000000000000000000000000000000000000000000001",
176185
)?;
@@ -214,6 +223,8 @@ cargo run -p aelf-sdk --example raw_transaction_flow
214223
- `AELF_AMOUNT`
215224
- `AELF_SEND`
216225

226+
如果没有提供 `AELF_PRIVATE_KEY``public_balance``dynamic_contract_get_balance` 会回退到公开的只读测试 key。这个 key 仅用于示例和 smoke test,绝对不要充值或承载资产。
227+
217228
## Feature Flags
218229

219230
v0.1 alpha 当前有一个传输层 feature:
@@ -430,6 +441,10 @@ MSRV 说明:
430441
- workspace 的 MSRV 现在是 Rust `1.85`
431442
- CI 已用 `cargo +1.85.0 check --workspace --all-targets --all-features --locked` 做硬性门禁。
432443

444+
## 安全
445+
446+
私下披露漏洞的方式见 [SECURITY.md](SECURITY.md)
447+
433448
## License
434449

435450
MIT

SECURITY.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Security Policy
2+
3+
## Supported Versions
4+
5+
Security fixes are applied to the latest maintained release line and the current `main` branch.
6+
7+
## Reporting a Vulnerability
8+
9+
Please report security vulnerabilities privately to `devops@aelf.io`.
10+
11+
Do not open a public GitHub issue for undisclosed security problems.
12+
13+
When reporting a vulnerability, include:
14+
15+
- affected crate or workflow
16+
- reproduction steps or proof of concept
17+
- impact assessment if known
18+
- any suggested mitigation
19+
20+
We will acknowledge receipt as soon as practical, investigate privately, and coordinate public disclosure after a fix is available.

crates/aelf-client/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ use zeroize::Zeroize;
4040

4141
const API_BASE: &str = "api/blockChain";
4242
const NET_API_BASE: &str = "api/net";
43+
// Public test-only readonly key used for system contract lookups. Never fund it.
4344
const READONLY_PRIVATE_KEY: &str =
4445
"0000000000000000000000000000000000000000000000000000000000000001";
4546

crates/aelf-contract/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,7 @@ mod tests {
719719
Arc,
720720
};
721721

722+
// Public test-only readonly key used by descriptor-related tests. Never fund it.
722723
const READONLY_PRIVATE_KEY: &str =
723724
"0000000000000000000000000000000000000000000000000000000000000001";
724725

crates/aelf-sdk/examples/dynamic_contract_get_balance.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
use aelf_sdk::{AElfClient, ClientConfig, Wallet};
22
use serde_json::json;
33

4+
// Public test-only readonly key for examples and smoke tests. Never fund it.
5+
const READONLY_PRIVATE_KEY: &str =
6+
"0000000000000000000000000000000000000000000000000000000000000001";
7+
48
#[tokio::main(flavor = "current_thread")]
59
async fn main() -> Result<(), Box<dyn std::error::Error>> {
610
let endpoint =
711
std::env::var("AELF_ENDPOINT").unwrap_or_else(|_| "http://127.0.0.1:8000".to_owned());
812
let token_address = std::env::var("AELF_TOKEN_CONTRACT")?;
913
let owner = std::env::var("AELF_OWNER_ADDRESS")?;
10-
let private_key = std::env::var("AELF_PRIVATE_KEY").unwrap_or_else(|_| {
11-
"0000000000000000000000000000000000000000000000000000000000000001".to_owned()
12-
});
14+
// Public test-only readonly key for examples and smoke tests. Never fund it.
15+
let private_key =
16+
std::env::var("AELF_PRIVATE_KEY").unwrap_or_else(|_| READONLY_PRIVATE_KEY.to_owned());
1317

1418
let client = AElfClient::new(ClientConfig::new(endpoint))?;
1519
let wallet = Wallet::from_private_key(&private_key)?;

0 commit comments

Comments
 (0)