Skip to content

Commit

Permalink
merge: #3998
Browse files Browse the repository at this point in the history
3998: fix(dal, web): Ensure attribute functions can't set incorrect output locations r=stack72 a=stack72

Without this, people can set root or root/secrets - which is the dangerous props people can set

We now made it:

/root/resource_value/*
/root/domain/*
/root/si/color

Co-authored-by: stack72 <[email protected]>
  • Loading branch information
si-bors-ng[bot] and stack72 authored Jun 19, 2024
2 parents 6125034 + 1b8df17 commit 23e71ca
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
20 changes: 11 additions & 9 deletions app/web/src/store/func/funcs.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,16 +280,18 @@ export const useFuncStore = () => {
(schemaVariantId === nilId()
? _.flatten(Object.values(this.inputSourceProps))
: this.inputSourceProps[schemaVariantId]
)?.map((prop) => {
const label = this.propIdToSourceName(prop.propId) ?? "none";
return {
label,
value: {
)
?.filter((p) => p.eligibleForOutput)
.map((prop) => {
const label = this.propIdToSourceName(prop.propId) ?? "none";
return {
label,
propId: prop.propId,
},
};
}) ?? [];
value: {
label,
propId: prop.propId,
},
};
}) ?? [];

const socketOptions =
(schemaVariantId === nilId()
Expand Down
1 change: 1 addition & 0 deletions app/web/src/store/func/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export interface InputSourceProp {
schemaVariantId: string;
path: string;
name: string;
eligibleForOutput: boolean;
}

export interface OutputLocationProp {
Expand Down
11 changes: 10 additions & 1 deletion lib/dal/src/input_sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pub struct InputSourceProp {
pub kind: PropKind,
pub name: String,
pub path: String,
pub eligible_for_output: bool,
}

#[derive(Deserialize, Serialize, Debug)]
Expand Down Expand Up @@ -151,12 +152,20 @@ impl InputSources {
work_queue.extend(Prop::direct_child_props_ordered(ctx, prop.id).await?);
}

let path = prop.path(ctx).await?.with_replaced_sep_and_prefix("/");

let eligible_for_output = path == "/root/resource_value"
|| path == "/root/si/color"
|| path.starts_with("/root/domain/")
|| path.starts_with("/root/resource_value/");

input_socket_props.push(InputSourceProp {
schema_variant_id,
prop_id: prop.id,
kind: prop.kind,
name: prop.name.to_owned(),
path: prop.path(ctx).await?.with_replaced_sep_and_prefix("/"),
path,
eligible_for_output,
})
}

Expand Down

0 comments on commit 23e71ca

Please sign in to comment.