Skip to content

Commit

Permalink
[backend] exclude some extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
SouadHadjiat committed Nov 17, 2023
1 parent beaab64 commit adbfffd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions opencti-platform/opencti-graphql/src/database/file-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export const isFileObjectExcluded = (id) => {
};

const simpleFilesListing = async (context, user, directory, opts = {}) => {
const { recursive = false, modifiedSince, maxFileSize, excludedPaths = [], includedPaths = [] } = opts;
const { recursive = false, modifiedSince, maxFileSize, excludedExtensions = [], excludedPaths = [], includedPaths = [] } = opts;
const storageObjects = [];
const requestParams = {
Bucket: bucketName,
Expand All @@ -222,6 +222,7 @@ const simpleFilesListing = async (context, user, directory, opts = {}) => {
}
const filteredObjects = storageObjects.filter((obj) => {
return !isFileObjectExcluded(obj.Key)
&& (!excludedExtensions?.length || !excludedExtensions.some((ext) => obj.Key.endsWith(ext)))
&& (!modifiedSince || obj.LastModified > modifiedSince)
&& (!maxFileSize || maxFileSize >= obj.Size)
&& (!includedPaths?.length || includedPaths.some((includedPath) => obj.Key.startsWith(includedPath)))
Expand Down Expand Up @@ -359,7 +360,8 @@ export const filesListing = async (context, user, first, path, entity = null, pr

export const fileListingForIndexing = async (context, user, path, opts = {}) => {
const fileListingForIndexingFn = async () => {
const files = await simpleFilesListing(context, user, path, { ...opts, recursive: true });
const excludedExtensions = ['.exe', '.json'];
const files = await simpleFilesListing(context, user, path, { ...opts, excludedExtensions, recursive: true });
return files.sort((a, b) => a.LastModified - b.LastModified);
};
return telemetry(context, user, `STORAGE ${path}`, {
Expand Down

0 comments on commit adbfffd

Please sign in to comment.