Skip to content

Commit

Permalink
[Osquery] Fix issue with exporting/importing prebuilt packs (#129577) (
Browse files Browse the repository at this point in the history
…#129648)

(cherry picked from commit c59f8b4)

Co-authored-by: Patryk Kopyciński <[email protected]>
  • Loading branch information
kibanamachine and patrykkopycinski authored Apr 6, 2022
1 parent e5456c1 commit b0e0311
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,18 @@ export const savedQueryType: SavedObjectsType = {
path: `/app/osquery/saved_queries/${savedObject.id}`,
uiCapabilitiesPath: 'osquery.read',
}),
onExport: (context, objects) =>
produce(objects, (draft) => {
draft.forEach((savedQuerySO) => {
// Only prebuilt saved queries should have a version
if (savedQuerySO.attributes.version) {
savedQuerySO.attributes.id += '_copy';
delete savedQuerySO.attributes.version;
}
});

return draft;
}),
},
};

Expand Down Expand Up @@ -138,6 +150,11 @@ export const packType: SavedObjectsType = {
produce(objects, (draft) => {
draft.forEach((packSO) => {
packSO.references = [];
// Only prebuilt packs should have a version
if (packSO.attributes.version) {
packSO.attributes.name += '_copy';
delete packSO.attributes.version;
}
});

return draft;
Expand Down

0 comments on commit b0e0311

Please sign in to comment.