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
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@ on:
branches: [master, main]
pull_request:

permissions:
contents: read

jobs:
in-cli:
name: in-cli (fmt/clippy/test)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
Expand All @@ -29,6 +34,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@stable
- name: Build protocol-gen
run: cargo build --bin protocol-gen
Expand All @@ -44,6 +51,8 @@ jobs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@stable
- name: Install rust-src
run: rustup component add rust-src
Expand All @@ -64,6 +73,8 @@ jobs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@stable
- name: Install rust-src
run: rustup component add rust-src
Expand All @@ -80,6 +91,8 @@ jobs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@stable
- name: Install rust-src
run: rustup component add rust-src
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ jobs:
timeout-minutes: 90
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@stable
- name: Install rust-src (for self-host sysroot)
run: rustup component add rust-src
Expand Down Expand Up @@ -67,6 +69,8 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
"symbol": "fiber_greet",
"returns": "string",
"invoke": {
"program": "sh",
"program": "go",
"args": [
"-c",
"cd inauguration-invoke && go run ."
"run",
"./inauguration-invoke"
]
}
}
]
}
}
1 change: 1 addition & 0 deletions in-cli/Cargo.lock

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

1 change: 1 addition & 0 deletions in-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ libc = "0.2"
quote = "1"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
sha1 = "0.11"
sha2 = "0.11"
syn = { version = "2", features = ["full"] }
thiserror = "2"
Expand Down
16 changes: 15 additions & 1 deletion in-cli/src/package_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ fn verify_archive_checksum(path: &Path, checksum: &ArtifactChecksum) -> Result<(
match checksum {
ArtifactChecksum::Sha1Hex(expected) => verify_hex_digest(
expected,
&hex_encode(&sha2::Sha256::digest(&data)),
&hex_encode(&sha1::Sha1::digest(&data)),
path,
"sha1",
),
Expand Down Expand Up @@ -1045,6 +1045,7 @@ fn curl_to_file(url: &str, path: &Path) -> Result<(), String> {
})?;
}
let status = Command::new("curl")
.env_clear()
.args([
"-fsSL",
"-A",
Expand Down Expand Up @@ -1079,6 +1080,13 @@ pub fn lock_dependencies(path: &Path) -> Result<(PathBuf, PackageLock), String>
mod tests {
use super::*;

#[test]
fn require_https_rejects_non_https() {
assert!(require_https("https://example.com/pkg").is_ok());
assert!(require_https("http://example.com/pkg").is_err());
assert!(require_https("file:///tmp/pkg").is_err());
}

#[test]
fn verify_archive_checksum_error_paths() {
let dir = tempfile_dir("verify-checksum-err");
Expand All @@ -1087,6 +1095,12 @@ mod tests {

let sha1 = ArtifactChecksum::Sha1Hex("badsha1".to_string());
assert!(verify_archive_checksum(&path, &sha1).is_err());
let sha1_ok =
ArtifactChecksum::Sha1Hex("2aae6c35c94fcfb415dbe95f408b9ce91ee846ed".to_string());
assert!(
verify_archive_checksum(&path, &sha1_ok).is_ok(),
"npm shasum is SHA-1 of the archive bytes, not SHA-256"
);

let sha256 = ArtifactChecksum::Sha256Hex("badsha256".to_string());
assert!(verify_archive_checksum(&path, &sha256).is_err());
Expand Down
12 changes: 11 additions & 1 deletion in-cli/src/package_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pub fn invoke_package_export(
}
}

const ALLOWED_INVOKE_PROGRAMS: &[&str] = &["echo", "node", "python3", "cargo", "go", "sh", "true"];
const ALLOWED_INVOKE_PROGRAMS: &[&str] = &["echo", "node", "python3", "cargo", "go", "true"];

pub fn run_invoke(spec: &PackageInvokeSpec, install_path: &Path) -> Result<String, String> {
if !ALLOWED_INVOKE_PROGRAMS.contains(&spec.program.as_str()) {
Expand Down Expand Up @@ -176,6 +176,16 @@ mod tests {
assert_eq!(value, Value::String("ok".to_string()));
}

#[test]
fn rejects_shell_invoke_program() {
let spec = PackageInvokeSpec {
program: "sh".to_string(),
args: vec!["-c".to_string(), "echo pwned".to_string()],
};
let err = run_invoke(&spec, Path::new(".")).expect_err("sh must not be allowlisted");
assert!(err.contains("not in the allowlist"));
}

#[test]
fn test_binding_return_type_mapping() {
let cases = vec![
Expand Down
Loading