-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #569 from opencybersecurityalliance/k2-fix-nonexis…
…t-projection fix nonexist projection
- Loading branch information
Showing
5 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import yaml | ||
from kestrel.utils import list_folder_files | ||
|
||
MAPPING_MODULE = "kestrel.mapping" | ||
|
||
# cache type mapping | ||
type_mapping = {} | ||
|
||
|
||
def get_type_from_projection(proj) -> str: | ||
global type_mapping | ||
if not type_mapping: | ||
for f in list_folder_files(MAPPING_MODULE, "types", extension="yaml"): | ||
with open(f, "r") as fp: | ||
mapping_ind = yaml.safe_load(fp) | ||
type_mapping.update(mapping_ind) | ||
if proj in type_mapping: | ||
return type_mapping[proj] | ||
else: | ||
return "unkown_entity" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters