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
5 changes: 0 additions & 5 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,6 @@ TWIGPINE_REQUIRE_SIGNATURE_NONCE=false
# Example: /ip4/1.2.3.4/udp/7546/quic-v1/p2p/12D3KooW...
TWIGPINE_P2P_BOOTSTRAP=

# ── Access control ────────────────────────────────────────────────────────
# Reserved and currently inert. Repo reads are gated per repository by
# is_public and path-scoped visibility rules; this flag changes nothing.
TWIGPINE_PUBLIC_READ=true

# Maximum git smart-HTTP pack request size, in bytes.
TWIGPINE_MAX_PACK_BYTES=2147483648

Expand Down
27 changes: 26 additions & 1 deletion crates/twigpine-cli/src/doctor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,11 @@ pub async fn run(args: DoctorArgs) -> Result<()> {

// Settings still given under their names from before the rename. They
// work; this row only appears when there is something to update.
if let Some(check) = legacy_settings_check(&twigpine_core::legacy_env::report()) {
let mut legacy = twigpine_core::legacy_env::report();
if let Some(check) = removed_public_read_check(&mut legacy) {
checks.push(check);
}
if let Some(check) = legacy_settings_check(&legacy) {
checks.push(check);
}

Expand Down Expand Up @@ -631,6 +635,27 @@ fn which_in_path(name: &str) -> bool {
.unwrap_or(false)
}

const REMOVED_PUBLIC_READ: &str = "TWIGPINE_PUBLIC_READ";

/// Drop the removed public-read setting from the legacy report and return
/// its own removal-notice row when either name is set, even if empty.
fn removed_public_read_check(report: &mut twigpine_core::legacy_env::Report) -> Option<Check> {
if std::env::var_os("TWIGPINE_PUBLIC_READ").is_none()
&& std::env::var_os("GITLAWB_PUBLIC_READ").is_none()
{
return None;
}
report
.legacy_only
.retain(|name| name != REMOVED_PUBLIC_READ);
report.conflicts.retain(|name| name != REMOVED_PUBLIC_READ);
Some(Check::warn(
"public read",
"TWIGPINE_PUBLIC_READ and GITLAWB_PUBLIC_READ were removed and have no effect. Reads follow each repository's visibility.",
"unset TWIGPINE_PUBLIC_READ and GITLAWB_PUBLIC_READ in your shell profile or service unit",
))
}

/// Fetch the latest release tag from Twigpine/node (the actual release repo — see install.sh's
/// `TWIGPINE_RELEASE_REPO` default) and compare to current version.
/// A warn row naming settings given under their old `GITLAWB_` names, or
Expand Down
70 changes: 70 additions & 0 deletions crates/twigpine-cli/tests/doctor_transport_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -833,3 +833,73 @@ fn no_settings_row_without_an_old_name() {
let r = doctor_with(Some(&url), None, &[]);
assert!(settings_row(&r).is_none(), "{}", r.stdout);
}

/// The row doctor prints when a removed public-read setting is present.
fn public_read_row(r: &Run) -> Option<&str> {
r.stdout
.lines()
.find(|l| l.contains("were removed and have no effect"))
}

#[test]
fn a_removed_public_read_setting_is_not_reported_as_working() {
for env in [
vec![("GITLAWB_PUBLIC_READ", "false")],
vec![("TWIGPINE_PUBLIC_READ", "true")],
vec![("GITLAWB_PUBLIC_READ", "")],
vec![
("TWIGPINE_PUBLIC_READ", "true"),
("GITLAWB_PUBLIC_READ", "false"),
],
] {
let (port, _) = serve(|_, _| did_ok());
let url = format!("http://127.0.0.1:{port}");
let r = doctor_with(Some(&url), None, &env);
let row = public_read_row(&r)
.unwrap_or_else(|| panic!("no removed public-read row for {env:?}:\n{}", r.stdout));
assert!(
row.contains("Reads follow each repository's visibility."),
"{row}"
);
assert!(
settings_row(&r).is_none(),
"the removed setting must not be reported as working ({env:?}):\n{}",
r.stdout
);
assert_eq!(
r.stdout
.matches("TWIGPINE_PUBLIC_READ and GITLAWB_PUBLIC_READ were removed and have no effect. Reads follow each repository's visibility.")
.count(),
1,
"the removal notice must appear exactly once ({env:?}):\n{}",
r.stdout
);
}
}

#[test]
fn the_removed_public_read_row_does_not_hide_other_old_names() {
let (port, _) = serve(|_, _| did_ok());
let url = format!("http://127.0.0.1:{port}");
let r = doctor_with(
None,
None,
&[("GITLAWB_NODE", &url), ("GITLAWB_PUBLIC_READ", "false")],
);
let row = settings_row(&r).unwrap_or_else(|| panic!("no settings row:\n{}", r.stdout));
assert!(row.contains("TWIGPINE_NODE"), "{row}");
assert!(!row.contains("PUBLIC_READ"), "{row}");
assert!(
public_read_row(&r).is_some(),
"no removed public-read row:\n{}",
r.stdout
);
}

#[test]
fn no_public_read_row_when_unset() {
let (port, _) = serve(|_, _| did_ok());
let url = format!("http://127.0.0.1:{port}");
let r = doctor_with(Some(&url), None, &[]);
assert!(public_read_row(&r).is_none(), "{}", r.stdout);
}
29 changes: 3 additions & 26 deletions crates/twigpine-node/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,6 @@ pub struct Config {
#[arg(long, env = "TWIGPINE_KEY", default_value = DEFAULT_KEY_PATH)]
pub key_path: String,

/// Reserved and currently inert: read access is enforced per repository
/// through `is_public` and path-scoped visibility rules, not this flag.
/// Setting it to false changes nothing; make a repo private through its
/// own visibility instead.
#[arg(long, env = "TWIGPINE_PUBLIC_READ", default_value_t = true)]
pub public_read: bool,

/// Public URL of this node (for peer announcements)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
#[arg(long, env = "TWIGPINE_PUBLIC_URL")]
pub public_url: Option<String>,
Expand Down Expand Up @@ -2685,26 +2678,10 @@ mod tests {
);
}

/// #338: TWIGPINE_PUBLIC_READ is inert, so its help must not claim read
/// enforcement is missing; it must tell the operator the flag changes
/// nothing and where the real control lives.
#[test]
fn public_read_help_describes_the_flag_as_inert() {
use clap::CommandFactory;
let cmd = Config::command();
let arg = cmd
.get_arguments()
.find(|a| a.get_id() == "public_read")
.expect("the argument must exist");
let help = arg.get_help().map(|h| h.to_string()).unwrap_or_default();
assert!(
!help.contains("not wired"),
"the help still claims read enforcement is unwired: {help}"
);
assert!(
help.contains("inert"),
"the help must say the flag is inert so an operator does not rely on it: {help}"
);
fn public_read_flag_is_not_accepted() {
let error = Config::try_parse_from(["twigpine-node", "--public-read"]).unwrap_err();
assert_eq!(error.kind(), clap::error::ErrorKind::UnknownArgument);
}

/// The flip must not strand an operator mid-upgrade.
Expand Down
18 changes: 11 additions & 7 deletions crates/twigpine-node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,20 @@ pub async fn run() -> Result<()> {

let mut config = Config::parse_with_sources();

const PUBLIC_READ: &str = "TWIGPINE_PUBLIC_READ";
let mut legacy = twigpine_core::legacy_env::report();
if std::env::var_os(PUBLIC_READ).is_some() || std::env::var_os("GITLAWB_PUBLIC_READ").is_some()
{
legacy.legacy_only.retain(|name| name != PUBLIC_READ);
legacy.conflicts.retain(|name| name != PUBLIC_READ);
warn!(
"TWIGPINE_PUBLIC_READ and GITLAWB_PUBLIC_READ were removed and have no effect. Reads follow each repository's visibility."
);
}

// Settings given under their names from before the rename still work
// (`main` copied them over before anything read a setting). Say which, by
// name only, so an operator can update the unit file at leisure.
let legacy = twigpine_core::legacy_env::report();
if !legacy.legacy_only.is_empty() {
info!(
settings = %legacy.legacy_only.join(", "),
Expand Down Expand Up @@ -144,12 +154,6 @@ pub async fn run() -> Result<()> {
.validate()
.map_err(|e| anyhow::anyhow!("invalid configuration: {e}"))?;

if !config.public_read {
warn!(
"TWIGPINE_PUBLIC_READ=false has no effect; reads are gated per repository by is_public and path-scoped visibility rules, not this flag"
);
}

// Load or generate the node's identity keypair
let keypair = Arc::new(load_or_create_keypair(&config)?);
// Sealing key for the legacy-scan continuation tokens, DERIVED from the identity
Expand Down
39 changes: 39 additions & 0 deletions crates/twigpine-node/tests/public_read_startup.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
use std::process::Command;

#[test]
fn warns_once_for_either_removed_public_read_env_var() {
let warning = "TWIGPINE_PUBLIC_READ and GITLAWB_PUBLIC_READ were removed and have no effect. Reads follow each repository's visibility.";
for (current, legacy) in [
(None, None),
(Some(""), None),
(None, Some("false")),
(Some("true"), Some("false")),
] {
let mut cmd = Command::new(env!("CARGO_BIN_EXE_twigpine-node"));
cmd.env_clear().env("RUST_LOG", "info").args([
"--upstream-mirror-enabled",
"--enforce-owner-push",
"false",
]);
if let Some(value) = current {
cmd.env("TWIGPINE_PUBLIC_READ", value);
}
if let Some(value) = legacy {
cmd.env("GITLAWB_PUBLIC_READ", value);
}
let output = cmd.output().unwrap();
let stdout = String::from_utf8_lossy(&output.stdout);
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(!output.status.success());
assert!(stderr.contains("invalid configuration: TWIGPINE_UPSTREAM_MIRROR_ENABLED requires"));
assert_eq!(
stdout.matches(warning).count(),
usize::from(current.is_some() || legacy.is_some()),
"{stdout}"
);
assert!(!stdout.contains("these settings were given under their old GITLAWB_ names"));
assert!(
!stdout.contains("these settings have a different value under their old GITLAWB_ name")
);
}
}
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ services:
# rolling-upgrade opt-out reachable for an operator running compose.
TWIGPINE_ENFORCE_OWNER_PUSH: ${TWIGPINE_ENFORCE_OWNER_PUSH:-${GITLAWB_ENFORCE_OWNER_PUSH:-true}}
TWIGPINE_P2P_BOOTSTRAP: ${TWIGPINE_P2P_BOOTSTRAP:-${GITLAWB_P2P_BOOTSTRAP:-}}
TWIGPINE_PUBLIC_READ: ${TWIGPINE_PUBLIC_READ:-${GITLAWB_PUBLIC_READ:-true}}
TWIGPINE_MAX_PACK_BYTES: ${TWIGPINE_MAX_PACK_BYTES:-${GITLAWB_MAX_PACK_BYTES:-2147483648}}
# Sync
TWIGPINE_AUTO_SYNC: ${TWIGPINE_AUTO_SYNC:-${GITLAWB_AUTO_SYNC:-false}}
Expand Down
11 changes: 5 additions & 6 deletions docs/OSS-READINESS-AUDIT.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Live-network blockers to prioritize:
- GraphQL POST is still open for compatibility; GraphQL mutations should get mutation-aware auth before it becomes a public write API surface.
- Push authorization is still not capability-complete. A valid DID signature is authentication, not authorization. Owner checks are now enforced on every branch, protected or not (`GITLAWB_ENFORCE_OWNER_PUSH`, on by default); what remains is that a UCAN `git/push` capability is not yet honored, so a delegated or CI key cannot push.
- UCAN chain validation is incomplete and UCAN revocation/blocklisting is not implemented as an operator feature.
- Private repository reads are enforced per repository through `is_public` and path-scoped visibility rules. `GITLAWB_PUBLIC_READ` remains reserved and inert.
- Private repository reads are enforced per repository through `is_public` and path-scoped visibility rules.
- Peer URLs are self-asserted by DIDs. Signatures prove control of the DID key when present, not ownership/safety of the announced URL.
- Outbound peer fetch/ping/sync paths should be reviewed for SSRF protections before accepting arbitrary public peer registrations.

Expand Down Expand Up @@ -146,11 +146,10 @@ Risks:
## Obvious live-network priorities

1. Implement repo write authorization: owner checks, UCAN capability checks, and clear delegation semantics for push/PR/issue/bounty operations.
2. Private reads are already enforced per repository (`is_public` plus path-scoped rules); retire the reserved and inert `GITLAWB_PUBLIC_READ` flag or document it as permanently reserved.
3. Add UCAN revocation/blocklisting and operator docs for emergency key compromise.
4. Harden peer registration and outbound fetch behavior against SSRF and peer-list poisoning.
5. Add Docker/installer/release smoke tests to CI.
6. Label PoS/economics docs consistently with the current live contract and rewards status.
2. Add UCAN revocation/blocklisting and operator docs for emergency key compromise.
3. Harden peer registration and outbound fetch behavior against SSRF and peer-list poisoning.
4. Add Docker/installer/release smoke tests to CI.
5. Label PoS/economics docs consistently with the current live contract and rewards status.

## Status updates (post-snapshot)

Expand Down