chore(#1055): address argus review nits

- rename cap-cap-col → cap-col; add CSS rules for .cap-col and .cap-save-col
- drop zero-width-space replace in capability header cells (nowrap makes it a no-op)
- add Capability::ALL to hive-sh4re; validate incoming cap strings in post_capabilities
This commit is contained in:
iris 2026-06-02 09:23:50 +02:00 committed by mara
commit c7f02993d0
4 changed files with 22 additions and 2 deletions

View file

@ -2077,6 +2077,12 @@ body.logs-shell {
text-align: left !important;
min-width: 8em;
}
.cap-col {
min-width: 5em;
}
.cap-save-col {
min-width: 4em;
}
.cap-agent-name {
color: var(--fg);
font-weight: 600;

View file

@ -1221,7 +1221,7 @@ window.marked = marked;
const hrow = el('tr');
hrow.append(el('th', { class: 'cap-agent-col' }, 'agent'));
for (const c of caps) {
hrow.append(el('th', { class: 'cap-cap-col', title: c }, c.replace(/_/g, '_')));
hrow.append(el('th', { class: 'cap-col', title: c }, c));
}
hrow.append(el('th', { class: 'cap-save-col' }, ''));
thead.append(hrow);
@ -1240,7 +1240,7 @@ window.marked = marked;
const checkboxes = [];
for (const c of caps) {
const checked = assigned.includes(c);
const td = el('td', { class: 'cap-cap-col' });
const td = el('td', { class: 'cap-col' });
const cb = el('input', {
type: 'checkbox',
class: 'cap-cb',

View file

@ -2595,6 +2595,12 @@ async fn post_capabilities(
if let Some(reject) = guard_agent_name(&state, &logical).await {
return reject;
}
let known: Vec<&str> = hive_sh4re::Capability::ALL.iter().map(|c| c.as_str()).collect();
for cap in &body.caps {
if !known.contains(&cap.as_str()) {
return error_response(&format!("unknown capability: {cap}"));
}
}
if let Err(e) = crate::capabilities::set_caps(&logical, &body.caps) {
return error_response(&format!("set capabilities for {logical}: {e}"));
}

View file

@ -923,6 +923,14 @@ pub enum Capability {
}
impl Capability {
/// Every known capability in a stable order. Use this to enumerate
/// columns in the permissions UI or validate incoming capability strings.
pub const ALL: &'static [Self] = &[
Self::ManageRootAgent,
Self::ReadHostJournal,
Self::QueryAgentState,
];
/// Canonical `snake_case` name for this capability (matches serde).
#[must_use]
pub fn as_str(self) -> &'static str {