Skip to content

Commit

Permalink
Bugfix: Artifactset parameter type should only return summaries (Velo…
Browse files Browse the repository at this point in the history
…cidex#3636)

Previously the entire artifact definitions were returned which would
exceed the grpc limit.

Also fixed by with favorites saving for server artifacts
  • Loading branch information
scudette authored Jul 23, 2024
1 parent f5af319 commit 05563cc
Show file tree
Hide file tree
Showing 7 changed files with 540 additions and 487 deletions.
10 changes: 10 additions & 0 deletions api/artifacts.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,16 @@ func searchArtifact(
new_item.Type = artifact.Type
}

if fields.Sources {
for _, s := range artifact.Sources {
new_item.Sources = append(new_item.Sources,
&artifacts_proto.ArtifactSource{
Name: s.Name,
Description: s.Description,
})
}
}

result.Items = append(result.Items, new_item)
}
}
Expand Down
360 changes: 185 additions & 175 deletions api/proto/artifacts.pb.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api/proto/artifacts.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ message FieldSelector {
bool name = 1;
bool description = 2;
bool type = 3;
bool sources = 4;
}

message GetArtifactsRequest {
Expand Down
602 changes: 306 additions & 296 deletions artifacts/proto/artifact.pb.go

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions artifacts/proto/artifact.proto
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ message ArtifactParameter {

// For type = artifactset
string artifact_type = 8;

// For type = artifactset;
bool sources = 9;
}

message NotebookSourceCell {
Expand Down
1 change: 1 addition & 0 deletions gui/velociraptor/src/components/flows/flows-list.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ class FlowsList extends React.Component {
}
{ this.state.showSaveCollectionDialog &&
<SaveCollectionDialog
client={this.props.client}
flow={this.props.selected_flow}
onClose={e=>{
this.setState({showSaveCollectionDialog: false});
Expand Down
50 changes: 34 additions & 16 deletions gui/velociraptor/src/components/forms/form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,19 @@ export default class VeloForm extends React.Component {
this.source.cancel();
this.source = CancelToken.source();

let fields = {name: true};
if (this.props.param.sources) {
fields["sources"] = true;
};

// Load all artifacts, but only keep the ones that match the
// specified type
api.post("v1/GetArtifacts",
{
search_term: "...",
type: artifact_type,

// No field type: We want the list of sources too
fields: fields,

// This might be too many to fetch at once but we
// are still fast enough for now.
Expand Down Expand Up @@ -168,6 +173,10 @@ export default class VeloForm extends React.Component {
}
}

if(_.isEmpty(sources)) {
selectable_names.push(desc.name);
}

// If there is a mix of unnamed sources and named
// sources, put the bare artifact name first so the
// UI will be visually consistent.
Expand Down Expand Up @@ -479,6 +488,17 @@ export default class VeloForm extends React.Component {
</Form.Group>
);
}

let a_options = [];
let a_defaults = [];

_.each(this.state.multichoices, (v, k)=>{
a_options.push({value: k, label: k});
if(v.enabled) {
a_defaults.push({value: k, label: k});
}
});

return (
<Form.Group as={Row}>
<Form.Label column sm="3">
Expand All @@ -491,21 +511,19 @@ export default class VeloForm extends React.Component {
</OverlayTrigger>
</Form.Label>
<Col sm="8">
{ _.map(Object.keys(this.state.multichoices), (key, idx) => {
return (
<OverlayTrigger
key={key}
delay={{show: 250, hide: 400}}
overlay={(props)=>renderToolTip(props, this.state.multichoices[key])}>
<div>
<Form.Switch label={key}
id={key}
checked={this.state.multichoices[key].enabled}
onChange={this.setMulti.bind(this, key)} />
</div>
</OverlayTrigger>
);
})}
<Select
placeholder={T("Choose one or more items")}
className="velo"
classNamePrefix="velo"
closeMenuOnSelect={false}
isMulti
defaultValue={a_defaults}
onChange={e=>{
let data = _.map(e, x=>x.value);
this.props.setValue(JSON.stringify(data));
}}
options={a_options}
/>
</Col>
</Form.Group>
);
Expand Down

0 comments on commit 05563cc

Please sign in to comment.