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
24 changes: 24 additions & 0 deletions .github/workflows/near-tools.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: near-tools

on:
push:
branches: [main]
paths:
- "scripts/near/**"
- ".github/workflows/near-tools.yml"
pull_request:
paths:
- "scripts/near/**"
- ".github/workflows/near-tools.yml"

permissions:
contents: read

jobs:
credential-output:
name: credential output regression tests
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
- run: python3 -m unittest discover -s scripts/near -p 'test_*.py' -v
61 changes: 18 additions & 43 deletions contracts/approval/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions contracts/approval/contract/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ crate-type = ["cdylib", "rlib"]

[dependencies]
approval-core = { path = "../core", features = ["borsh"] }
near-sdk = "5.29"
# Use Rust's standard allocator instead of the SDK's unmaintained wee_alloc default.
near-sdk = { version = "5.29", default-features = false }

[dev-dependencies]
near-sdk = { version = "5.29", features = ["unit-testing"] }
near-sdk = { version = "5.29", default-features = false, features = ["unit-testing"] }

# `cargo near build reproducible-wasm` builds inside this pinned image, so the
# wasm's code hash can be reproduced from the source at a given commit.
Expand Down
17 changes: 17 additions & 0 deletions scripts/near/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,23 @@ for commit `081a3a6`).
| `.sandbox/`, `.cache/` | Local sandbox state and the cargo-near download cache (gitignored). |
| `../../.near-credentials/` | Principal key files (gitignored). |

## Credential output regression tests

From the repository root, run:

```bash
python3 -m unittest discover -s scripts/near -p 'test_*.py' -v
```

The tests use a public RFC 8032 test vector to check that key-management
commands print only the public key, never its private seed or full secret.
They also check error output, CLI redaction, and mode 0600 on generated
credential files. NEAR ed25519 secret keys encode `seed || public_key`;
`parse_secret_key` exposes only the last 32 bytes as its public-key result.
CodeQL can carry the input's sensitive-data label onto that public result,
so its clear-text logging alerts on these public-key outputs are false
positives. Secret values still belong only in private files.

## Limitations

- Only ed25519 keys are generated and accepted for `NEAR_PRIVATE_KEY`.
Expand Down
7 changes: 6 additions & 1 deletion scripts/near/near_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@ def b58decode(text):


def parse_secret_key(secret):
"""ed25519:<base58 of 64 bytes seed||pub> -> (secret_str, public_key_str)."""
"""ed25519:<base58 of 64 bytes seed||pub> -> (secret_str, public_key_str).

Only the final 32 bytes form the public key returned in the second slot.
Printing that value is intentional: no seed bytes are included. The full
secret in the first slot must only be written to private credential files.
"""
secret = secret.strip()
if not secret.startswith("ed25519:"):
if secret.startswith("secp256k1:"):
Expand Down
Loading
Loading