Skip to content

Commit 87f93f3

Browse files
Merge pull request #75 from aethelred-foundation/codex/final-share
Tighten final share-readiness guards
2 parents bc6203b + 7a8543d commit 87f93f3

4 files changed

Lines changed: 42 additions & 6 deletions

File tree

.github/workflows/developer-tools-ci.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,18 @@ jobs:
4444
cli: ${{ steps.filter.outputs.cli }}
4545
vscode_extension: ${{ steps.filter.outputs.vscode_extension }}
4646
dashboard: ${{ steps.filter.outputs.dashboard }}
47+
dashboard_package: ${{ steps.dashboard_package.outputs.exists }}
4748
local_testnet: ${{ steps.filter.outputs.local_testnet }}
4849
steps:
4950
- uses: actions/checkout@v4
51+
- name: Detect dashboard package manifest
52+
id: dashboard_package
53+
run: |
54+
if [ -f frontend/dashboard/package.json ]; then
55+
echo "exists=true" >> "$GITHUB_OUTPUT"
56+
else
57+
echo "exists=false" >> "$GITHUB_OUTPUT"
58+
fi
5059
- uses: dorny/paths-filter@v3
5160
id: filter
5261
with:
@@ -140,7 +149,7 @@ jobs:
140149
dashboard-build:
141150
runs-on: ubuntu-latest
142151
needs: changes
143-
if: ${{ (github.event_name == 'workflow_dispatch' || needs.changes.outputs.dashboard == 'true') && hashFiles('frontend/dashboard/package.json') != '' }}
152+
if: ${{ (github.event_name == 'workflow_dispatch' || needs.changes.outputs.dashboard == 'true') && needs.changes.outputs.dashboard_package == 'true' }}
144153
steps:
145154
- uses: actions/checkout@v4
146155

crates/vault/src/validator_selection.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ use crate::types::*;
1717
/// Maximum score for any individual dimension (basis points).
1818
const MAX_SCORE: u32 = 10_000;
1919

20+
/// Bound internal allocations even if an external caller supplies an
21+
/// unexpectedly large target count.
22+
const MAX_SELECTION_CAPACITY: usize = 10_000;
23+
2024
/// Select validators from candidates using the TEE scoring algorithm.
2125
///
2226
/// # Algorithm
@@ -224,7 +228,11 @@ fn apply_diversity_constraints(
224228
let candidate_map: HashMap<String, &ValidatorInput> =
225229
candidates.iter().map(|v| (v.address.clone(), v)).collect();
226230

227-
let selection_capacity = target_count.min(scored.len()).min(candidates.len());
231+
let selection_capacity = scored
232+
.len()
233+
.min(candidates.len())
234+
.min(target_count)
235+
.min(MAX_SELECTION_CAPACITY);
228236
let mut region_count: HashMap<String, usize> = HashMap::new();
229237
let mut operator_count: HashMap<String, usize> = HashMap::new();
230238
let mut selected_addrs: HashSet<String> = HashSet::with_capacity(selection_capacity);

third_party/proto/table_marshal.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3001,11 +3001,22 @@ func (p *Buffer) Marshal(pb Message) error {
30013001
// grow grows the buffer's capacity, if necessary, to guarantee space for
30023002
// another n bytes. After grow(n), at least n bytes can be written to the
30033003
// buffer without another allocation.
3004+
func checkedBufferGrowth(current, add int) (int, bool) {
3005+
if current < 0 || add < 0 {
3006+
return 0, false
3007+
}
3008+
need64 := uint64(current) + uint64(add)
3009+
if need64 > uint64(math.MaxInt) {
3010+
return 0, false
3011+
}
3012+
return int(need64), true
3013+
}
3014+
30043015
func (p *Buffer) grow(n int) {
3005-
if n < 0 || len(p.buf) > math.MaxInt-n {
3016+
need, ok := checkedBufferGrowth(len(p.buf), n)
3017+
if !ok {
30063018
panic(ErrTooLarge)
30073019
}
3008-
need := len(p.buf) + n
30093020
if need <= cap(p.buf) {
30103021
return
30113022
}

tools/cli/src/commands/config_cmd.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,23 @@ fn set_value(config: &Config, key: &str, value: &str) -> Result<()> {
5151
.set(key, value)
5252
.with_context(|| format!("failed to set '{key}'"))?;
5353
updated.save(None).context("failed to save config")?;
54-
println!("Set {key} = {}", display_value(key, value));
54+
if is_sensitive_key(key) {
55+
println!("Set {key} = [REDACTED]");
56+
} else {
57+
println!("Set {key} = {value}");
58+
}
5559
Ok(())
5660
}
5761

5862
fn get_value(config: &Config, key: &str) -> Result<()> {
5963
let value = config
6064
.get(key)
6165
.ok_or_else(|| anyhow!("key '{key}' not found"))?;
62-
println!("{}", display_value(key, &value));
66+
if is_sensitive_key(key) {
67+
println!("[REDACTED]");
68+
} else {
69+
println!("{value}");
70+
}
6371
Ok(())
6472
}
6573

0 commit comments

Comments
 (0)