Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix on instance trigger incorrect message when updating the standard Id #6199

Merged
merged 3 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { ENTITY_TYPE_RESOLVED_FILTERS } from '../../schema/stixDomainObject';
import { extractFilterGroupValues, isFilterGroupNotEmpty } from './filtering-utils';
import { ENTITY_TYPE_STATUS } from '../../schema/internalObject';
import type { BasicWorkflowStatus } from '../../types/store';
import { STIX_EXT_OCTI } from '../../types/stix-extensions';

// list of all filters that needs resolution
export const RESOLUTION_FILTERS = [
Expand Down Expand Up @@ -125,7 +126,7 @@ export const resolveFilterGroup = async (
/**
* Build a resolution map thanks to the cache
*/
const buildResolutionMapForFilter = async (context: AuthContext, user: AuthUser, filter: Filter, cache: Map<string, StixObject>) : Promise<FilterResolutionMap> => {
const buildResolutionMapForFilter = async (context: AuthContext, user: AuthUser, filter: Filter, cache: Map<string, StixObject>): Promise<FilterResolutionMap> => {
const map: Map<string, string> = new Map();
if (Object.keys(STIX_RESOLUTION_MAP_PATHS).includes(filter.key[0])) {
for (let index = 0; index < filter.values.length; index += 1) {
Expand All @@ -139,8 +140,9 @@ const buildResolutionMapForFilter = async (context: AuthContext, user: AuthUser,
if (!(await isUserCanAccessStixElement(context, user, cachedObject))) {
// invalidate the filter value; it won't match ever, but we keep track of this invalidation for debug purposes
map.set(v, '<restricted-or-deleted>');
} else if (filter.key[0] === CONNECTED_TO_INSTANCE_FILTER) {
map.set(v, cachedObject.extensions[STIX_EXT_OCTI].id);
} else {
// resolve according to path
const cachedValue = cachedObject[path];
if (typeof cachedValue === 'string') {
map.set(v, cachedValue);
Expand All @@ -153,7 +155,7 @@ const buildResolutionMapForFilter = async (context: AuthContext, user: AuthUser,
return map;
};

const mergeMaps = <K, V>(mapArray: Map<K, V>[]) : Map<K, V> => {
const mergeMaps = <K, V>(mapArray: Map<K, V>[]): Map<K, V> => {
const mergedMap = new Map<K, V>();

mapArray.forEach((map) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ export const testConnectedTo = (stix: any, filter: Filter) => {
if (filter.operator && filter.operator !== 'eq') {
return false;
}
return testStringFilter(filter, [stix.id]);
return testStringFilter(filter, [stix.extensions[STIX_EXT_OCTI].id]);
};

/**
Expand Down