Skip to content

Commit

Permalink
keep track of http related configuration keys.
Browse files Browse the repository at this point in the history
We also select the most important few for implementation.
The most time-consuming part would be to implement overrides correctly
and validate it against the baseline of git, it's unclear how git
can be queried or made to leak certain information. Maybe by overriding
DNS mappings to let it go against an unknown local IP/port?
  • Loading branch information
Byron committed Nov 8, 2022
1 parent cf04218 commit 1afaebd
Show file tree
Hide file tree
Showing 2 changed files with 184 additions and 12 deletions.
4 changes: 4 additions & 0 deletions git-repository/src/discover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ impl ThreadSafeRepository {
///
/// Finally, use the `trust_map` to determine which of our own repository options to use
/// based on the trust level of the effective repository directory.
// TODO: GIT_HTTP_PROXY_AUTHMETHOD, GIT_PROXY_SSL_CERT, GIT_PROXY_SSL_KEY, GIT_PROXY_SSL_CERT_PASSWORD_PROTECTED.
// GIT_PROXY_SSL_CAINFO, GIT_SSL_VERSION, GIT_SSL_CIPHER_LIST, GIT_HTTP_MAX_REQUESTS, GIT_CURL_FTP_NO_EPSV,
// GIT_HTTP_LOW_SPEED_LIMIT, GIT_HTTP_LOW_SPEED_TIME, GIT_HTTP_USER_AGENT
// The vars above should end up as overrides of the respective configuration values (see git-config).
pub fn discover_with_environment_overrides_opts(
directory: impl AsRef<Path>,
mut options: upwards::Options,
Expand Down
192 changes: 180 additions & 12 deletions src/plumbing/progress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,18 @@ use tabled::{Style, TableIteratorExt, Tabled};

#[derive(Clone)]
enum Usage {
NotApplicable {
reason: &'static str,
},
NotPlanned {
reason: &'static str,
},
Planned {
note: Option<&'static str>,
},
/// It's not reasonable to implement it as the prerequisites don't apply.
NotApplicable { reason: &'static str },
/// We have no intention to implement it, but that can change if there is demand.
NotPlanned { reason: &'static str },
/// We definitely want to implement this configuration value.
Planned { note: Option<&'static str> },
/// The configuration is already effective and used (at least) in the given module `name`.
InModule {
name: &'static str,
deviation: Option<&'static str>,
},
/// Needs analysis
/// Needs analysis, unclear how it works or what it does.
Puzzled,
}
use Usage::*;
Expand Down Expand Up @@ -544,6 +542,154 @@ static GIT_CONFIG: &[Record] = &[
config: "index.version",
usage: Planned { note: Some("once V4 indices can be written, we need to be able to set a desired version. For now we write the smallest possible index version only.") },
},
Record {
config: "http.proxy",
usage: Planned { note: None },
},
Record {
config: "http.extraHeader",
usage: Planned { note: Some("multi-value, and resettable with empty value") },
},
Record {
config: "http.proxyAuthMethod",
usage: Planned { note: None },
},
Record {
config: "http.proxySSLCert",
usage: NotPlanned { reason: "on demand" }
},
Record {
config: "http.proxySSLKey",
usage: NotPlanned { reason: "on demand" }
},
Record {
config: "http.proxySSLCertPasswordProtected",
usage: NotPlanned { reason: "on demand" }
},
Record {
config: "http.proxySSLCAInfo",
usage: NotPlanned { reason: "on demand" }
},
Record {
config: "http.emptyAuth",
usage: NotPlanned { reason: "on demand" }
},
Record {
config: "http.delegation",
usage: NotPlanned { reason: "on demand" }
},
Record {
config: "http.cookieFile",
usage: NotPlanned { reason: "on demand" }
},
Record {
config: "http.saveCookies",
usage: NotPlanned { reason: "on demand" }
},
Record {
config: "http.version",
usage: NotPlanned { reason: "on demand" }
},
Record {
config: "http.curloptResolve",
usage: NotPlanned { reason: "on demand" }
},
Record {
config: "http.sslVersion",
usage: NotPlanned { reason: "on demand" }
},
Record {
config: "http.sslCipherList",
usage: NotPlanned { reason: "on demand" }
},
Record {
config: "http.sslCipherList",
usage: NotPlanned { reason: "on demand" }
},
Record {
config: "http.sslVerify",
usage: NotPlanned { reason: "on demand" }
},
Record {
config: "http.sslCert",
usage: NotPlanned { reason: "on demand" }
},
Record {
config: "http.sslKey",
usage: NotPlanned { reason: "on demand" }
},
Record {
config: "http.sslCertPasswordProtected",
usage: NotPlanned { reason: "on demand" }
},
Record {
config: "http.sslCertPasswordProtected",
usage: NotPlanned { reason: "on demand" }
},
Record {
config: "http.sslCAInfo",
usage: NotPlanned { reason: "on demand" }
},
Record {
config: "http.sslCAPath",
usage: NotPlanned { reason: "on demand" }
},
Record {
config: "http.sslBackend",
usage: NotPlanned { reason: "on demand" }
},
Record {
config: "http.schannelCheckRevoke",
usage: NotPlanned { reason: "on demand" }
},
Record {
config: "http.schannelUseSSLCAInfo",
usage: NotPlanned { reason: "on demand" }
},
Record {
config: "http.pinnedPubkey",
usage: NotPlanned { reason: "on demand" }
},
Record {
config: "http.sslTry",
usage: NotPlanned { reason: "on demand" }
},
Record {
config: "http.maxRequests",
usage: NotPlanned { reason: "on demand" }
},
Record {
config: "http.minSessions",
usage: NotPlanned { reason: "on demand" }
},
Record {
config: "http.postBuffer",
usage: Planned { note: Some("relevant when implementing push, we should understand how memory allocation works when streaming") }
},
Record {
config: "http.lowSpeedLimit",
usage: Planned { note: Some("important for client-safety when facing bad networks or bad players") }
},
Record {
config: "http.lowSpeedTime",
usage: Planned { note: Some("important for client-safety when facing bad networks or bad players") }
},
Record {
config: "http.userAgent",
usage: Planned { note: None }
},
Record {
config: "http.noEPSV",
usage: NotPlanned { reason: "on demand" }
},
Record {
config: "http.followRedirects",
usage: Planned { note: None }
},
Record {
config: "http.<url>.*",
usage: Planned { note: Some("it's a vital part of git configuration. It's unclear how to get a baseline from git for this one.") }
},
Record {
config: "sparse.expectFilesOutsideOfPatterns",
usage: NotPlanned { reason: "todo" },
Expand All @@ -559,7 +705,19 @@ static GIT_CONFIG: &[Record] = &[
usage: Planned {
note: Some("required for big monorepos, and typically used in conjunction with sparse indices")
}
}
},
Record {
config: "remote.<name>.proxy",
usage: Planned {
note: None
}
},
Record {
config: "remote.<name>.proxyAuthMethod",
usage: Planned {
note: None
}
},
];

/// A programmatic way to record and display progress.
Expand All @@ -572,7 +730,7 @@ pub fn show_progress() -> anyhow::Result<()> {

println!("{}", sorted.table().with(Style::blank()));
println!(
"\nTotal records: {} ({perfect_icon} = {perfect}, {deviation_icon} = {deviation}, {planned_icon} = {planned})",
"\nTotal records: {} ({perfect_icon} = {perfect}, {deviation_icon} = {deviation}, {planned_icon} = {planned}, {ondemand_icon} = {ondemand}, {not_applicable_icon} = {not_applicable})",
GIT_CONFIG.len(),
perfect_icon = InModule {
name: "",
Expand All @@ -586,13 +744,23 @@ pub fn show_progress() -> anyhow::Result<()> {
.icon(),
planned_icon = Planned { note: None }.icon(),
planned = GIT_CONFIG.iter().filter(|e| matches!(e.usage, Planned { .. })).count(),
ondemand_icon = NotPlanned { reason: "" }.icon(),
not_applicable_icon = NotApplicable { reason: "" }.icon(),
perfect = GIT_CONFIG
.iter()
.filter(|e| matches!(e.usage, InModule { deviation, .. } if deviation.is_none()))
.count(),
deviation = GIT_CONFIG
.iter()
.filter(|e| matches!(e.usage, InModule { deviation, .. } if deviation.is_some()))
.count(),
ondemand = GIT_CONFIG
.iter()
.filter(|e| matches!(e.usage, NotPlanned { .. }))
.count(),
not_applicable = GIT_CONFIG
.iter()
.filter(|e| matches!(e.usage, NotApplicable { .. }))
.count()
);
Ok(())
Expand Down

0 comments on commit 1afaebd

Please sign in to comment.