pidsmaker 5.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (339) hide show
  1. pidsmaker/__init__.py +1 -0
  2. pidsmaker/cli.py +81 -0
  3. pidsmaker/config/__init__.py +2 -0
  4. pidsmaker/config/config.py +2100 -0
  5. pidsmaker/config/pipeline.py +1824 -0
  6. pidsmaker/config/schemas.py +1032 -0
  7. pidsmaker/datasets.py +323 -0
  8. pidsmaker/debug_tests.py +30 -0
  9. pidsmaker/decoders/__init__.py +5 -0
  10. pidsmaker/decoders/custom_edge_mlp_decoder.py +17 -0
  11. pidsmaker/decoders/custom_mlp_decoder.py +10 -0
  12. pidsmaker/decoders/edge_linear_decoder.py +16 -0
  13. pidsmaker/decoders/inner_product_decoder.py +18 -0
  14. pidsmaker/decoders/nodlink_decoder.py +56 -0
  15. pidsmaker/detection/__init__.py +0 -0
  16. pidsmaker/detection/evaluation_methods/__init__.py +9 -0
  17. pidsmaker/detection/evaluation_methods/edge_evaluation.py +255 -0
  18. pidsmaker/detection/evaluation_methods/evaluation_utils.py +1788 -0
  19. pidsmaker/detection/evaluation_methods/host_two_stage_evaluation.py +115 -0
  20. pidsmaker/detection/evaluation_methods/node_evaluation.py +459 -0
  21. pidsmaker/detection/evaluation_methods/node_tw_evaluation.py +196 -0
  22. pidsmaker/detection/evaluation_methods/plot.py +192 -0
  23. pidsmaker/detection/evaluation_methods/queue_evaluation.py +456 -0
  24. pidsmaker/detection/evaluation_methods/tw_evaluation.py +93 -0
  25. pidsmaker/detection/flash_detection.py +162 -0
  26. pidsmaker/detection/magic_knn.py +190 -0
  27. pidsmaker/detection/node_scoring.py +52 -0
  28. pidsmaker/detection/threatrace_detection.py +65 -0
  29. pidsmaker/detection/training_methods/__init__.py +1 -0
  30. pidsmaker/detection/training_methods/inference_loop.py +287 -0
  31. pidsmaker/detection/training_methods/ocrapt_early_stop.py +165 -0
  32. pidsmaker/detection/training_methods/threatrace_training.py +168 -0
  33. pidsmaker/detection/training_methods/training_loop.py +383 -0
  34. pidsmaker/encoders/__init__.py +22 -0
  35. pidsmaker/encoders/argus_encoder.py +69 -0
  36. pidsmaker/encoders/custom_mlp.py +75 -0
  37. pidsmaker/encoders/custom_mlp_encoder.py +10 -0
  38. pidsmaker/encoders/egraphsage_encoder.py +56 -0
  39. pidsmaker/encoders/gat.py +67 -0
  40. pidsmaker/encoders/gcn.py +27 -0
  41. pidsmaker/encoders/gin.py +48 -0
  42. pidsmaker/encoders/glstm.py +298 -0
  43. pidsmaker/encoders/graph_attention.py +63 -0
  44. pidsmaker/encoders/gru.py +29 -0
  45. pidsmaker/encoders/hetero/__init__.py +4 -0
  46. pidsmaker/encoders/hetero/ancestor_encoder.py +98 -0
  47. pidsmaker/encoders/hetero/entity_encoder.py +33 -0
  48. pidsmaker/encoders/hetero/event_encoder.py +81 -0
  49. pidsmaker/encoders/hetero/hetero_graph_transformer.py +40 -0
  50. pidsmaker/encoders/lares_encoder.py +68 -0
  51. pidsmaker/encoders/linear_encoder.py +16 -0
  52. pidsmaker/encoders/magic_encoder.py +161 -0
  53. pidsmaker/encoders/rcaid_encoder.py +81 -0
  54. pidsmaker/encoders/rgcn.py +75 -0
  55. pidsmaker/encoders/sage.py +51 -0
  56. pidsmaker/encoders/shadewatcher_encoder.py +149 -0
  57. pidsmaker/encoders/sum_aggregation.py +20 -0
  58. pidsmaker/encoders/temporal_wrappers.py +80 -0
  59. pidsmaker/encoders/textrcnn.py +82 -0
  60. pidsmaker/encoders/tgn_encoder.py +193 -0
  61. pidsmaker/experiments/tuning.py +102 -0
  62. pidsmaker/experiments/uncertainty.py +261 -0
  63. pidsmaker/factory.py +1456 -0
  64. pidsmaker/featurization/__init__.py +0 -0
  65. pidsmaker/featurization/feat_inference_methods/__init__.py +7 -0
  66. pidsmaker/featurization/feat_inference_methods/feat_inference_HFH.py +30 -0
  67. pidsmaker/featurization/feat_inference_methods/feat_inference_TRW.py +65 -0
  68. pidsmaker/featurization/feat_inference_methods/feat_inference_alacarte.py +14 -0
  69. pidsmaker/featurization/feat_inference_methods/feat_inference_doc2vec.py +53 -0
  70. pidsmaker/featurization/feat_inference_methods/feat_inference_fasttext.py +37 -0
  71. pidsmaker/featurization/feat_inference_methods/feat_inference_flash.py +69 -0
  72. pidsmaker/featurization/feat_inference_methods/feat_inference_graph2vec.py +84 -0
  73. pidsmaker/featurization/feat_inference_methods/feat_inference_ocrapt_features.py +95 -0
  74. pidsmaker/featurization/feat_inference_methods/feat_inference_pretrained.py +1728 -0
  75. pidsmaker/featurization/feat_inference_methods/feat_inference_word2vec.py +55 -0
  76. pidsmaker/featurization/featurization_methods/__init__.py +0 -0
  77. pidsmaker/featurization/featurization_methods/build_trw.py +66 -0
  78. pidsmaker/featurization/featurization_methods/featurization_alacarte.py +747 -0
  79. pidsmaker/featurization/featurization_methods/featurization_doc2vec.py +98 -0
  80. pidsmaker/featurization/featurization_methods/featurization_fasttext.py +74 -0
  81. pidsmaker/featurization/featurization_methods/featurization_flash.py +201 -0
  82. pidsmaker/featurization/featurization_methods/featurization_graph2vec.py +242 -0
  83. pidsmaker/featurization/featurization_methods/featurization_trw.py +114 -0
  84. pidsmaker/featurization/featurization_methods/featurization_word2vec.py +89 -0
  85. pidsmaker/featurization/featurization_utils.py +275 -0
  86. pidsmaker/featurization/utils/build_random_walks.py +66 -0
  87. pidsmaker/featurization/utils/trw.py +203 -0
  88. pidsmaker/hetero.py +81 -0
  89. pidsmaker/losses.py +170 -0
  90. pidsmaker/main.py +478 -0
  91. pidsmaker/mimicry.py +284 -0
  92. pidsmaker/model.py +382 -0
  93. pidsmaker/objectives/__init__.py +16 -0
  94. pidsmaker/objectives/autoencode_edge_emb.py +43 -0
  95. pidsmaker/objectives/deep_graph_infomax.py +94 -0
  96. pidsmaker/objectives/detect_few_shot.py +21 -0
  97. pidsmaker/objectives/one_class.py +75 -0
  98. pidsmaker/objectives/predict_edge_contrastive.py +165 -0
  99. pidsmaker/objectives/predict_edge_supervised.py +77 -0
  100. pidsmaker/objectives/predict_edge_type.py +28 -0
  101. pidsmaker/objectives/predict_masked_struct.py +49 -0
  102. pidsmaker/objectives/predict_node_type.py +36 -0
  103. pidsmaker/objectives/predict_process_tag.py +169 -0
  104. pidsmaker/objectives/predict_snapshot_embedding.py +97 -0
  105. pidsmaker/objectives/reconstruct_edge_emb.py +16 -0
  106. pidsmaker/objectives/reconstruct_masked_feat.py +51 -0
  107. pidsmaker/objectives/reconstruct_node_emb.py +13 -0
  108. pidsmaker/objectives/reconstruct_node_feat.py +13 -0
  109. pidsmaker/objectives/validation_wrapper.py +55 -0
  110. pidsmaker/preprocessing/__init__.py +0 -0
  111. pidsmaker/preprocessing/build_graph_methods/__init__.py +1 -0
  112. pidsmaker/preprocessing/build_graph_methods/build_default_graphs.py +825 -0
  113. pidsmaker/preprocessing/build_graph_methods/build_magic_graphs.py +216 -0
  114. pidsmaker/preprocessing/cleaning.py +258 -0
  115. pidsmaker/preprocessing/transformation_methods/__init__.py +2 -0
  116. pidsmaker/preprocessing/transformation_methods/attack_generation/synthetic_attack_naive.py +194 -0
  117. pidsmaker/preprocessing/transformation_methods/transformation_dag.py +28 -0
  118. pidsmaker/preprocessing/transformation_methods/transformation_merge_edges.py +136 -0
  119. pidsmaker/preprocessing/transformation_methods/transformation_rcaid_pseudo_graph.py +510 -0
  120. pidsmaker/preprocessing/transformation_methods/transformation_undirected.py +24 -0
  121. pidsmaker/preprocessing/transformation_methods/transformation_utils.py +36 -0
  122. pidsmaker/pretrained/__init__.py +5 -0
  123. pidsmaker/pretrained/data/__init__.py +4 -0
  124. pidsmaker/pretrained/data/behavior_signatures.py +548 -0
  125. pidsmaker/pretrained/data/canonical_tokens.py +1035 -0
  126. pidsmaker/pretrained/data/edge_filter.py +381 -0
  127. pidsmaker/pretrained/data/entity_classes.py +476 -0
  128. pidsmaker/pretrained/data/sampler.py +926 -0
  129. pidsmaker/pretrained/data/tokenizer_bpe.py +1659 -0
  130. pidsmaker/pretrained/detect.py +1427 -0
  131. pidsmaker/pretrained/embedding_generator.py +252 -0
  132. pidsmaker/pretrained/finetune.py +1434 -0
  133. pidsmaker/pretrained/models/__init__.py +20 -0
  134. pidsmaker/pretrained/models/behavior.py +348 -0
  135. pidsmaker/pretrained/models/bert.py +286 -0
  136. pidsmaker/pretrained/models/deepwalk.py +128 -0
  137. pidsmaker/pretrained/models/dgi.py +120 -0
  138. pidsmaker/pretrained/models/gae.py +114 -0
  139. pidsmaker/pretrained/models/gnn_distill.py +475 -0
  140. pidsmaker/pretrained/models/graphmae.py +373 -0
  141. pidsmaker/pretrained/models/hf_pretrained.py +213 -0
  142. pidsmaker/pretrained/models/llama.py +110 -0
  143. pidsmaker/pretrained/models/modernbert.py +567 -0
  144. pidsmaker/pretrained/models/roberta.py +147 -0
  145. pidsmaker/pretrained/models/rope_utils.py +99 -0
  146. pidsmaker/pretrained/models/ropebert.py +322 -0
  147. pidsmaker/pretrained/models/spider.py +204 -0
  148. pidsmaker/pretrained/models/tgn.py +770 -0
  149. pidsmaker/pretrained/pretrain/__init__.py +3 -0
  150. pidsmaker/pretrained/pretrain/pretrain_behavior_cluster.py +513 -0
  151. pidsmaker/pretrained/pretrain/pretrain_common.py +585 -0
  152. pidsmaker/pretrained/pretrain/pretrain_deepwalk.py +31 -0
  153. pidsmaker/pretrained/pretrain/pretrain_dgi.py +143 -0
  154. pidsmaker/pretrained/pretrain/pretrain_gae.py +143 -0
  155. pidsmaker/pretrained/pretrain/pretrain_gnn_distill.py +438 -0
  156. pidsmaker/pretrained/pretrain/pretrain_graphmae.py +151 -0
  157. pidsmaker/pretrained/pretrain/pretrain_hf.py +169 -0
  158. pidsmaker/pretrained/pretrain/pretrain_main.py +275 -0
  159. pidsmaker/pretrained/pretrain/pretrain_mlm.py +491 -0
  160. pidsmaker/pretrained/pretrain/pretrain_spider.py +502 -0
  161. pidsmaker/pretrained/training_utils.py +157 -0
  162. pidsmaker/process_reapr_gt.py +101 -0
  163. pidsmaker/resources/config/anomal_e.yml +25 -0
  164. pidsmaker/resources/config/argus.yml +56 -0
  165. pidsmaker/resources/config/attack_edges/cadets_e3.yml +435 -0
  166. pidsmaker/resources/config/attack_edges/cadets_e5.yml +407 -0
  167. pidsmaker/resources/config/attack_edges/theia_e3.yml +382 -0
  168. pidsmaker/resources/config/attack_edges/theia_e5.yml +387 -0
  169. pidsmaker/resources/config/attack_edges/trace_e3.yml +415 -0
  170. pidsmaker/resources/config/attack_edges/trace_e5.yml +417 -0
  171. pidsmaker/resources/config/default.yml +315 -0
  172. pidsmaker/resources/config/egraphsage.yml +95 -0
  173. pidsmaker/resources/config/euler.yml +104 -0
  174. pidsmaker/resources/config/eval/eval_set_clustering.json +3170 -0
  175. pidsmaker/resources/config/experiments/tuning/components/tuning_featurization_methods.yml +29 -0
  176. pidsmaker/resources/config/experiments/tuning/systems/clearscope_e5/tuning_orthrus.yml +14 -0
  177. pidsmaker/resources/config/experiments/tuning/systems/default/tuning_default_baselines.yml +13 -0
  178. pidsmaker/resources/config/experiments/tuning/systems/default/tuning_orthrus_fixed.yml +16 -0
  179. pidsmaker/resources/config/experiments/uncertainty/none.yml +5 -0
  180. pidsmaker/resources/config/experiments/uncertainty/run_n_times.yml +12 -0
  181. pidsmaker/resources/config/experiments/uncertainty/run_n_times_hyperparameters.yml +12 -0
  182. pidsmaker/resources/config/experiments/uncertainty/uncertainty.yml +22 -0
  183. pidsmaker/resources/config/flash.yml +79 -0
  184. pidsmaker/resources/config/jbeil.yml +65 -0
  185. pidsmaker/resources/config/kairos.yml +121 -0
  186. pidsmaker/resources/config/lares.yml +115 -0
  187. pidsmaker/resources/config/magic.yml +86 -0
  188. pidsmaker/resources/config/nodlink.yml +79 -0
  189. pidsmaker/resources/config/ocrapt.yml +91 -0
  190. pidsmaker/resources/config/orthrus.yml +126 -0
  191. pidsmaker/resources/config/orthrus_fixed.yml +17 -0
  192. pidsmaker/resources/config/pretrained/README.md +101 -0
  193. pidsmaker/resources/config/pretrained/cybergfm/cybergfm.yml +49 -0
  194. pidsmaker/resources/config/pretrained/pretrained.yml +190 -0
  195. pidsmaker/resources/config/pretrained/pretrained_flash.yml +9 -0
  196. pidsmaker/resources/config/pretrained/pretrained_kairos.yml +12 -0
  197. pidsmaker/resources/config/pretrained/pretrained_magic.yml +1 -0
  198. pidsmaker/resources/config/pretrained/pretrained_nodlink.yml +1 -0
  199. pidsmaker/resources/config/pretrained/pretrained_orthrus.yml +1 -0
  200. pidsmaker/resources/config/pretrained/pretrained_supervised.yml +13 -0
  201. pidsmaker/resources/config/pretrained/pretrained_threatrace.yml +8 -0
  202. pidsmaker/resources/config/pretrained/pretrained_velox.yml +14 -0
  203. pidsmaker/resources/config/prographer.yml +136 -0
  204. pidsmaker/resources/config/rcaid.yml +88 -0
  205. pidsmaker/resources/config/shadewatcher.yml +146 -0
  206. pidsmaker/resources/config/tests.yml +10 -0
  207. pidsmaker/resources/config/threatrace.yml +73 -0
  208. pidsmaker/resources/config/tuned_baselines/optc_net/tuned_argus.yml +4 -0
  209. pidsmaker/resources/config/tuned_baselines/optc_net/tuned_lares.yml +13 -0
  210. pidsmaker/resources/config/velox.yml +10 -0
  211. pidsmaker/resources/config/viz_config.yml +10 -0
  212. pidsmaker/resources/ground_truth/orthrus/E3-CADETS/node_Nginx_Backdoor_06.csv +8 -0
  213. pidsmaker/resources/ground_truth/orthrus/E3-CADETS/node_Nginx_Backdoor_11.csv +4 -0
  214. pidsmaker/resources/ground_truth/orthrus/E3-CADETS/node_Nginx_Backdoor_12.csv +43 -0
  215. pidsmaker/resources/ground_truth/orthrus/E3-CADETS/node_Nginx_Backdoor_13.csv +24 -0
  216. pidsmaker/resources/ground_truth/orthrus/E3-CLEARSCOPE/node_clearscope_e3_firefox_0411.csv +41 -0
  217. pidsmaker/resources/ground_truth/orthrus/E3-CLEARSCOPE/node_clearscope_e3_firefox_0412.csv +0 -0
  218. pidsmaker/resources/ground_truth/orthrus/E3-FIVEDIRECTIONS/node_fivedirections_e3_browser_0412.csv +1 -0
  219. pidsmaker/resources/ground_truth/orthrus/E3-FIVEDIRECTIONS/node_fivedirections_e3_excel_0409.csv +63 -0
  220. pidsmaker/resources/ground_truth/orthrus/E3-FIVEDIRECTIONS/node_fivedirections_e3_firefox_0411.csv +56 -0
  221. pidsmaker/resources/ground_truth/orthrus/E3-THEIA/node_Browser_Extension_Drakon_Dropper.csv +61 -0
  222. pidsmaker/resources/ground_truth/orthrus/E3-THEIA/node_Firefox_Backdoor_Drakon_In_Memory.csv +58 -0
  223. pidsmaker/resources/ground_truth/orthrus/E3-TRACE/node_trace_e3_firefox_0410.csv +11 -0
  224. pidsmaker/resources/ground_truth/orthrus/E3-TRACE/node_trace_e3_phishing_executable_0413.csv +11 -0
  225. pidsmaker/resources/ground_truth/orthrus/E3-TRACE/node_trace_e3_pine_0413.csv +14 -0
  226. pidsmaker/resources/ground_truth/orthrus/E5-CADETS/node_Nginx_Drakon_APT.csv +19 -0
  227. pidsmaker/resources/ground_truth/orthrus/E5-CADETS/node_Nginx_Drakon_APT_17.csv +107 -0
  228. pidsmaker/resources/ground_truth/orthrus/E5-CLEARSCOPE/node_clearscope_e5_appstarter_0515.csv +26 -0
  229. pidsmaker/resources/ground_truth/orthrus/E5-CLEARSCOPE/node_clearscope_e5_firefox_0517.csv +1 -0
  230. pidsmaker/resources/ground_truth/orthrus/E5-CLEARSCOPE/node_clearscope_e5_lockwatch_0517.csv +17 -0
  231. pidsmaker/resources/ground_truth/orthrus/E5-CLEARSCOPE/node_clearscope_e5_tester_0517.csv +8 -0
  232. pidsmaker/resources/ground_truth/orthrus/E5-FIVEDIRECTIONS/node_fivedirections_e5_bits_0515.csv +54 -0
  233. pidsmaker/resources/ground_truth/orthrus/E5-FIVEDIRECTIONS/node_fivedirections_e5_copykatz_0509.csv +87 -0
  234. pidsmaker/resources/ground_truth/orthrus/E5-FIVEDIRECTIONS/node_fivedirections_e5_dns_0517.csv +11 -0
  235. pidsmaker/resources/ground_truth/orthrus/E5-FIVEDIRECTIONS/node_fivedirections_e5_drakon_0517.csv +6 -0
  236. pidsmaker/resources/ground_truth/orthrus/E5-THEIA/node_THEIA_1_Firefox_Drakon_APT_BinFmt_Elevate_Inject.csv +70 -0
  237. pidsmaker/resources/ground_truth/orthrus/E5-TRACE/node_Trace_Firefox_Drakon.csv +71 -0
  238. pidsmaker/resources/ground_truth/orthrus/atlasv2_edr/atlasv2_edr_m1.csv +1 -0
  239. pidsmaker/resources/ground_truth/orthrus/atlasv2_edr/atlasv2_edr_m2.csv +1 -0
  240. pidsmaker/resources/ground_truth/orthrus/atlasv2_edr/atlasv2_edr_m3.csv +1 -0
  241. pidsmaker/resources/ground_truth/orthrus/atlasv2_edr/atlasv2_edr_m4.csv +5 -0
  242. pidsmaker/resources/ground_truth/orthrus/atlasv2_edr/atlasv2_edr_m5.csv +23 -0
  243. pidsmaker/resources/ground_truth/orthrus/atlasv2_edr/atlasv2_edr_m6.csv +18 -0
  244. pidsmaker/resources/ground_truth/orthrus/atlasv2_edr/atlasv2_edr_s1.csv +1 -0
  245. pidsmaker/resources/ground_truth/orthrus/atlasv2_edr/atlasv2_edr_s2.csv +1 -0
  246. pidsmaker/resources/ground_truth/orthrus/atlasv2_edr/atlasv2_edr_s3.csv +16 -0
  247. pidsmaker/resources/ground_truth/orthrus/atlasv2_edr/atlasv2_edr_s4.csv +22 -0
  248. pidsmaker/resources/ground_truth/orthrus/atlasv2_h1/node_h1_m1.csv +126 -0
  249. pidsmaker/resources/ground_truth/orthrus/atlasv2_h1/node_h1_m2.csv +105 -0
  250. pidsmaker/resources/ground_truth/orthrus/atlasv2_h1/node_h1_m3.csv +94 -0
  251. pidsmaker/resources/ground_truth/orthrus/atlasv2_h1/node_h1_m4.csv +139 -0
  252. pidsmaker/resources/ground_truth/orthrus/atlasv2_h1/node_h1_m5.csv +228 -0
  253. pidsmaker/resources/ground_truth/orthrus/atlasv2_h1/node_h1_m6.csv +131 -0
  254. pidsmaker/resources/ground_truth/orthrus/atlasv2_h1/node_h1_s1.csv +118 -0
  255. pidsmaker/resources/ground_truth/orthrus/atlasv2_h1/node_h1_s2.csv +89 -0
  256. pidsmaker/resources/ground_truth/orthrus/atlasv2_h1/node_h1_s3.csv +133 -0
  257. pidsmaker/resources/ground_truth/orthrus/atlasv2_h1/node_h1_s4.csv +135 -0
  258. pidsmaker/resources/ground_truth/orthrus/carbanakv2_edr/carbanakv2_edr.csv +2453 -0
  259. pidsmaker/resources/ground_truth/orthrus/h051/node_h051_0925.csv +114 -0
  260. pidsmaker/resources/ground_truth/orthrus/h201/node_h201_0923.csv +2905 -0
  261. pidsmaker/resources/ground_truth/orthrus/h501/node_h501_0924.csv +749 -0
  262. pidsmaker/resources/ground_truth/orthrus/readme.md +98 -0
  263. pidsmaker/resources/ground_truth/reapr/E3-CADETS/node_Nginx_Backdoor_06.csv +3 -0
  264. pidsmaker/resources/ground_truth/reapr/E3-CADETS/node_Nginx_Backdoor_12.csv +655 -0
  265. pidsmaker/resources/ground_truth/reapr/E3-CADETS/node_Nginx_Backdoor_13.csv +770 -0
  266. pidsmaker/resources/ground_truth/reapr/E3-FIVEDIRECTIONS/node_fivedirections_e3_excel_0409.csv +0 -0
  267. pidsmaker/resources/ground_truth/reapr/E3-FIVEDIRECTIONS/node_fivedirections_e3_firefox_0411.csv +18 -0
  268. pidsmaker/resources/ground_truth/reapr/E3-THEIA/node_Browser_Extension_Drakon_Dropper.csv +42 -0
  269. pidsmaker/resources/ground_truth/reapr/E3-THEIA/node_Firefox_Backdoor_Drakon_In_Memory.csv +81 -0
  270. pidsmaker/resources/ground_truth/reapr/E3-TRACE/node_trace_e3_firefox_0410.csv +37 -0
  271. pidsmaker/resources/ground_truth/reapr/E3-TRACE/node_trace_e3_phishing_executable_0413.csv +9 -0
  272. pidsmaker/resources/ground_truth/reapr/E3-TRACE/node_trace_e3_pine_0413.csv +40 -0
  273. pidsmaker/resources/ground_truth/threatrace/E3-CADETS/ground_truth.txt +12858 -0
  274. pidsmaker/resources/ground_truth/threatrace/E3-FIVEDIRECTIONS/ground_truth.txt +18420 -0
  275. pidsmaker/resources/ground_truth/threatrace/E3-THEIA/ground_truth.txt +25363 -0
  276. pidsmaker/resources/ground_truth/threatrace/E3-TRACE/ground_truth.txt +68265 -0
  277. pidsmaker/resources/ground_truth/threatrace/README.md +123 -0
  278. pidsmaker/tasks/__init__.py +10 -0
  279. pidsmaker/tasks/batching.py +47 -0
  280. pidsmaker/tasks/construction.py +31 -0
  281. pidsmaker/tasks/evaluation.py +241 -0
  282. pidsmaker/tasks/feat_inference.py +413 -0
  283. pidsmaker/tasks/featurization.py +43 -0
  284. pidsmaker/tasks/training.py +17 -0
  285. pidsmaker/tasks/transformation.py +306 -0
  286. pidsmaker/tasks/triage.py +143 -0
  287. pidsmaker/tgn.py +635 -0
  288. pidsmaker/tokenization/__init__.py +112 -0
  289. pidsmaker/tokenization/base.py +58 -0
  290. pidsmaker/tokenization/bpe_tokenizer.py +83 -0
  291. pidsmaker/tokenization/hf_tokenizer.py +61 -0
  292. pidsmaker/tokenization/hierarchical_tokenizer.py +44 -0
  293. pidsmaker/tokenization/label_tokenizer.py +24 -0
  294. pidsmaker/tokenization/nltk_tokenizer.py +84 -0
  295. pidsmaker/tokenization/substitution.py +295 -0
  296. pidsmaker/triage/__init__.py +0 -0
  297. pidsmaker/triage/tracing_methods/__init__.py +1 -0
  298. pidsmaker/triage/tracing_methods/depimpact.py +213 -0
  299. pidsmaker/triage/tracing_methods/depimpact_utils.py +537 -0
  300. pidsmaker/triage/tracing_methods/ocrapt_subgraph.py +267 -0
  301. pidsmaker/utils/__init__.py +0 -0
  302. pidsmaker/utils/cache_utils.py +256 -0
  303. pidsmaker/utils/console.py +282 -0
  304. pidsmaker/utils/data_utils.py +1742 -0
  305. pidsmaker/utils/database.py +150 -0
  306. pidsmaker/utils/dataset_utils.py +413 -0
  307. pidsmaker/utils/dataset_writer.py +570 -0
  308. pidsmaker/utils/graph_store.py +634 -0
  309. pidsmaker/utils/labelling.py +445 -0
  310. pidsmaker/utils/loss_files.py +193 -0
  311. pidsmaker/utils/process_tags.py +44 -0
  312. pidsmaker/utils/utils.py +712 -0
  313. pidsmaker/vizgen/__init__.py +1 -0
  314. pidsmaker/vizgen/backfill_manifests.py +100 -0
  315. pidsmaker/vizgen/dimensionality_reduction.py +249 -0
  316. pidsmaker/vizgen/embed_exporter.py +467 -0
  317. pidsmaker/vizgen/exporter.py +493 -0
  318. pidsmaker/vizgen/html_builder.py +936 -0
  319. pidsmaker/vizgen/web/__init__.py +1 -0
  320. pidsmaker/vizgen/web/export.py +62 -0
  321. pidsmaker/vizgen/web/static/css/app.css +250 -0
  322. pidsmaker/vizgen/web/static/index.html +182 -0
  323. pidsmaker/vizgen/web/static/js/app.js +627 -0
  324. pidsmaker/vizgen/web/static/js/campaign.js +123 -0
  325. pidsmaker/vizgen/web/static/js/data.js +119 -0
  326. pidsmaker/vizgen/web/static/js/dialogs.js +240 -0
  327. pidsmaker/vizgen/web/static/js/jobs.js +75 -0
  328. pidsmaker/vizgen/web/static/js/scene.js +651 -0
  329. pidsmaker/vizgen/web/static/js/ui.js +370 -0
  330. pidsmaker/vizgen/web/static/vendor/OrbitControls.js +1045 -0
  331. pidsmaker/vizgen/web/static/vendor/d3.v4.min.js +2 -0
  332. pidsmaker/vizgen/web/static/vendor/three.min.js +6 -0
  333. pidsmaker/vizgen/web/viz_server.py +2176 -0
  334. pidsmaker-5.0.0.dist-info/METADATA +597 -0
  335. pidsmaker-5.0.0.dist-info/RECORD +339 -0
  336. pidsmaker-5.0.0.dist-info/WHEEL +5 -0
  337. pidsmaker-5.0.0.dist-info/entry_points.txt +2 -0
  338. pidsmaker-5.0.0.dist-info/licenses/LICENSE +201 -0
  339. pidsmaker-5.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,169 @@
1
+ """Process tag prediction, the self-supervised objective of R-Caid (IEEE S&P 2024, Section 4.3).
2
+
3
+ Each process is annotated with the name of its executable (see `pidsmaker.utils.process_tags`),
4
+ and the GNN learns to predict it from its neighborhood and its roots: processes with the same
5
+ binary name get close embeddings. Only process nodes are classified (the paper found that
6
+ classifying all the nodes is detrimental); other nodes get a score of 0.
7
+
8
+ The classes are the tags of the processes of the training split, plus an "unknown" class for
9
+ the tags never seen in training, which is never a training target. Processes are scored either
10
+ as in the paper (`detection: kmeans`, see `ProcessTagPrediction`), which does not use the tags,
11
+ or by the loss of their tag (`detection: loss`), where a process running an executable never
12
+ seen in training gets a high loss.
13
+ """
14
+
15
+ import numpy as np
16
+ import torch
17
+ import torch.nn as nn
18
+ import torch.nn.functional as F
19
+
20
+ from pidsmaker.utils.process_tags import process_tag
21
+ from pidsmaker.utils.utils import compute_class_weights, get_indexid2msg, get_split2nodes, log
22
+
23
+ PROCESS_TYPE = "subject"
24
+
25
+
26
+ def build_process_tag_classes(indexid2msg, train_nodes, process_type=PROCESS_TYPE):
27
+ """(node id -> class array, number of known tags). Classes are numbered in order of
28
+ first appearance in the training processes (sorted by node id); -1: not a process,
29
+ `num_known`: process with an unknown tag."""
30
+ ids = sorted(int(n) for n in indexid2msg)
31
+ max_id = ids[-1] if ids else -1
32
+ classes = np.full(max_id + 1, -1, dtype=np.int64)
33
+ tag2class = {}
34
+ train_nodes = {str(n) for n in train_nodes}
35
+ for n in ids:
36
+ node_type, label = indexid2msg[str(n)] if str(n) in indexid2msg else indexid2msg[n]
37
+ if node_type == process_type and str(n) in train_nodes:
38
+ tag2class.setdefault(process_tag(label), len(tag2class))
39
+ num_known = len(tag2class)
40
+ for n in ids:
41
+ node_type, label = indexid2msg[str(n)] if str(n) in indexid2msg else indexid2msg[n]
42
+ if node_type == process_type:
43
+ classes[n] = tag2class.get(process_tag(label), num_known)
44
+ return classes, num_known
45
+
46
+
47
+ def process_tag_classes_from_cfg(cfg):
48
+ indexid2msg = get_indexid2msg(cfg)
49
+ train_nodes = get_split2nodes(cfg)["train"]
50
+ classes, num_known = build_process_tag_classes(indexid2msg, train_nodes)
51
+ log(f"Process tags: {num_known} tags in training, {(classes >= 0).sum()} processes")
52
+ return classes, num_known
53
+
54
+
55
+ def elbow_kmeans(x, k_values, seed=0, elbow_sample=5000):
56
+ """K-Means of x with the K at the elbow of the inertia curve over `k_values` (the point the
57
+ furthest from the line joining the first and last points, with normalized axes). The curve
58
+ is computed on a random sample of `elbow_sample` points."""
59
+ from sklearn.cluster import KMeans
60
+
61
+ k_values = [k for k in k_values if k <= len(x)] or [1]
62
+ sample = x
63
+ if len(x) > elbow_sample:
64
+ sample = x[np.random.default_rng(seed).choice(len(x), elbow_sample, replace=False)]
65
+ inertia = np.array(
66
+ [KMeans(n_clusters=k, n_init=3, random_state=seed).fit(sample).inertia_ for k in k_values]
67
+ )
68
+ best = len(k_values) - 1
69
+ if len(k_values) >= 3:
70
+ ks = np.array(k_values, dtype=float)
71
+ ks = (ks - ks[0]) / (ks[-1] - ks[0])
72
+ span = inertia[0] - inertia[-1]
73
+ inertia = (inertia - inertia[-1]) / span if span > 0 else np.zeros_like(inertia)
74
+ # Distance to the line from (0, 1) to (1, 0)
75
+ best = int(np.argmax(np.abs(ks + inertia - 1)))
76
+ return KMeans(n_clusters=k_values[best], n_init=3, random_state=seed).fit(x)
77
+
78
+
79
+ class ProcessTagPrediction(nn.Module):
80
+ """Process tag prediction. Inference scores (`detection`):
81
+
82
+ - `loss`: the cross-entropy of the tag of each process;
83
+ - `kmeans`: as in the paper (Section 4.4), the distance of the embedding of each process to
84
+ the median of its nearest cluster, clustered by K-Means (K chosen with the elbow method)
85
+ on the embeddings of training processes. These are sampled during the last training epoch
86
+ (up to `max_train_embeddings`, with dropout).
87
+ """
88
+
89
+ def __init__(self, decoder, node_classes, num_known, balanced_loss, detection="loss",
90
+ max_train_embeddings=20000, k_values=(2, 4, 6, 8, 10, 12, 16, 20, 25, 30)):
91
+ super(ProcessTagPrediction, self).__init__()
92
+ self.decoder = decoder
93
+ self.num_classes = num_known + 1 # + unknown
94
+ self.balanced_loss = balanced_loss
95
+ self.register_buffer("node_classes", torch.as_tensor(node_classes, dtype=torch.long), persistent=False)
96
+ if detection not in ("loss", "kmeans"):
97
+ raise ValueError(f"Invalid detection {detection}")
98
+ self.detection = detection
99
+ self.max_train_embeddings = max_train_embeddings
100
+ self.k_values = list(k_values)
101
+ self._generator = torch.Generator().manual_seed(0)
102
+ self.reset_state()
103
+
104
+ def reset_state(self):
105
+ """Called before each training epoch: the embeddings of the epoch are sampled again."""
106
+ self._train_embs = []
107
+ self._num_seen = 0
108
+ self._medians = None
109
+
110
+ def _sample_train_embeddings(self, h):
111
+ """Uniform sample of the embeddings seen in the epoch: each one gets a random key, and
112
+ those whose key is below `max_train_embeddings / number seen` are kept."""
113
+ h = h.detach().float().cpu()
114
+ keys = torch.rand(len(h), generator=self._generator)
115
+ self._num_seen += len(h)
116
+ ratio = min(1.0, self.max_train_embeddings / self._num_seen)
117
+ self._train_embs.append((h, keys))
118
+ self._train_embs = [(e[k < ratio], k[k < ratio]) for e, k in self._train_embs]
119
+ self._medians = None
120
+
121
+ def _cluster_medians(self, device):
122
+ if self._medians is None:
123
+ if not self._train_embs:
124
+ raise RuntimeError("`detection: kmeans` needs the embeddings of a training epoch")
125
+ x = torch.cat([e for e, _ in self._train_embs]).numpy()
126
+ km = elbow_kmeans(x, self.k_values)
127
+ medians = [np.median(x[km.labels_ == c], axis=0) for c in range(km.n_clusters)]
128
+ log(f"Process tags: K-Means with K={km.n_clusters} on {len(x)} training processes")
129
+ self._medians = torch.tensor(np.stack(medians), dtype=torch.float)
130
+ return self._medians.to(device)
131
+
132
+ def _classes(self, batch, num_nodes, device):
133
+ n_id = batch.original_n_id.to(device)
134
+ classes = torch.full((num_nodes,), -1, dtype=torch.long, device=device)
135
+ valid = n_id < self.node_classes.numel()
136
+ classes[valid] = self.node_classes[n_id[valid]]
137
+ return classes
138
+
139
+ def forward(self, h, inference, batch, **kwargs):
140
+ classes = self._classes(batch, h.shape[0], h.device)
141
+ is_process = classes >= 0
142
+
143
+ if not inference:
144
+ # Unknown tags (not in the training split) are never targets
145
+ known = is_process & (classes < self.num_classes - 1)
146
+ if not bool(known.any()):
147
+ return {"loss": h.sum() * 0.0}
148
+ if self.detection == "kmeans":
149
+ self._sample_train_embeddings(h[known])
150
+ logits = self.decoder(h[known])
151
+ target = classes[known]
152
+ weight = (
153
+ compute_class_weights(F.one_hot(target, self.num_classes), num_classes=self.num_classes)
154
+ if self.balanced_loss
155
+ else None
156
+ )
157
+ return {"loss": F.cross_entropy(logits, target, weight=weight)}
158
+
159
+ scores = torch.zeros(h.shape[0], dtype=torch.float, device=h.device)
160
+ out = None
161
+ if bool(is_process.any()):
162
+ logits = self.decoder(h[is_process])
163
+ out = F.log_softmax(logits, dim=1)
164
+ if self.detection == "kmeans":
165
+ dist = torch.cdist(h[is_process].float(), self._cluster_medians(h.device))
166
+ scores[is_process] = dist.min(dim=1).values
167
+ else:
168
+ scores[is_process] = F.cross_entropy(logits, classes[is_process], reduction="none")
169
+ return {"loss": scores, "out": out}
@@ -0,0 +1,97 @@
1
+ """Prediction of the embedding of the next snapshot, and key indicators (ProGrapher).
2
+
3
+ The encoder (`textrcnn`) predicts the graph2vec embedding of the current snapshot from the
4
+ previous ones. The loss of a snapshot is the L2 distance between its actual and predicted
5
+ embeddings (Eq. 6 of ProGrapher): the anomaly score of the snapshot.
6
+
7
+ At inference, the objective returns one score per node of the snapshot, so that ProGrapher is
8
+ evaluated per time window (`tw_evaluation`, as the paper) or per node (`node_evaluation`):
9
+
10
+ 1. Key indicators (Section 4.4). graph2vec predicts each rooted subgraph (RSG) r of a snapshot
11
+ from its embedding E with p(r | E) = softmax_r(w_r . E) over the RSGs of the snapshot (Eq. 1),
12
+ w_r being the output vector of r. The RSGs are ranked by the difference of their
13
+ log-likelihood under the actual and the predicted embeddings, log p(r | E) - log p(r | E'),
14
+ which reduces to w_r . (E - E') up to a constant of the snapshot: the RSGs best explained
15
+ by the actual snapshot, but not by its prediction, come first.
16
+ 2. Each node is ranked by the best rank of the RSGs rooted at it (one per WL depth): nodes
17
+ matching the top RSGs are the key indicators.
18
+ 3. The score of a node is `snapshot_score * (1 - rank / num_rsgs)`: the nodes of the top RSG
19
+ get the score of the snapshot, the others a fraction decreasing with the rank of their RSG.
20
+ With `top_k`, only the nodes matching the `top_k` first RSGs (the key indicators reported by
21
+ ProGrapher) keep a non-zero score.
22
+
23
+ The maximum node score of a snapshot is thus its own score: reduced with a max, as
24
+ `tw_evaluation` does with `max_val_loss`, node scores give the snapshot-level detection of the
25
+ paper.
26
+
27
+ RSGs unseen when training graph2vec are ignored, as when inferring the snapshot embedding.
28
+ """
29
+
30
+ import torch
31
+ import torch.nn as nn
32
+
33
+
34
+ class SnapshotEmbeddingPrediction(nn.Module):
35
+ def __init__(self, rsg_vectors, top_k=0):
36
+ """
37
+ Args:
38
+ rsg_vectors: (V, d) output vectors of the RSGs of graph2vec (`syn1neg`)
39
+ top_k: if > 0, only the nodes matching the `top_k` first RSGs get a score
40
+ """
41
+ super().__init__()
42
+ self.register_buffer("rsg_vectors", rsg_vectors.float(), persistent=False)
43
+ self.top_k = top_k
44
+ self.val_scores = []
45
+
46
+ def forward(self, h, inference, batch, validation=False, **kwargs):
47
+ target = batch.graph_emb.float().view(1, -1)
48
+ pred = h.view(1, -1)
49
+ score = torch.linalg.vector_norm(target - pred)
50
+
51
+ if not inference:
52
+ return {"loss": score}
53
+
54
+ if validation:
55
+ self.val_scores.append(score.item())
56
+ node_scores = score * self.key_indicator_weights(batch, (target - pred).view(-1))
57
+ return {"loss": node_scores}
58
+
59
+ @torch.no_grad()
60
+ def key_indicator_weights(self, batch, diff):
61
+ """Weight in [0, 1] of each node of the batch (in the order of `batch.original_n_id`)
62
+ given by the rank of its best RSG, the RSGs being ranked by w_r . diff."""
63
+ table = batch.snapshot_rsg[0].long() # (n, D + 2): node ID, then RSG IDs
64
+ rsg_ids = table[:, 1:]
65
+ known = rsg_ids >= 0
66
+
67
+ # Rank of the unique RSGs of the snapshot
68
+ uniq, inverse = torch.unique(rsg_ids[known], return_inverse=True)
69
+ num_rsgs = uniq.numel()
70
+ order = torch.argsort(self.rsg_vectors[uniq] @ diff, descending=True)
71
+ rank = torch.empty_like(order)
72
+ rank[order] = torch.arange(num_rsgs, device=order.device)
73
+
74
+ # Best rank of the RSGs of each node (num_rsgs if none is known)
75
+ node_rank = torch.full_like(rsg_ids, num_rsgs)
76
+ node_rank[known] = rank[inverse]
77
+ best_rank = node_rank.min(dim=1).values
78
+
79
+ weights = 1.0 - best_rank.float() / max(num_rsgs, 1)
80
+ if self.top_k > 0:
81
+ weights[best_rank >= self.top_k] = 0.0
82
+
83
+ # Nodes of the batch, found by ID in the table (sorted by node ID)
84
+ n_id = batch.original_n_id.long()
85
+ rows = torch.searchsorted(table[:, 0].contiguous(), n_id)
86
+ rows = rows.clamp(max=table.size(0) - 1)
87
+ if not torch.equal(table[rows, 0], n_id):
88
+ raise ValueError("Nodes of the batch are missing from the RSGs of their snapshot.")
89
+ return weights[rows]
90
+
91
+ def get_val_score(self):
92
+ """Validation score used by `best_model_selection=best_val_score`: the opposite of the
93
+ mean prediction error on the (benign) validation snapshots, as ProGrapher selects its
94
+ model on validation data."""
95
+ score = -sum(self.val_scores) / len(self.val_scores) if self.val_scores else 0.0
96
+ self.val_scores = []
97
+ return score
@@ -0,0 +1,16 @@
1
+ import torch
2
+ import torch.nn as nn
3
+
4
+
5
+ class EdgeEmbReconstruction(nn.Module):
6
+ def __init__(self, decoder, loss_fn):
7
+ super(EdgeEmbReconstruction, self).__init__()
8
+ self.decoder = decoder
9
+ self.loss_fn = loss_fn
10
+
11
+ def forward(self, h_src, h_dst, inference, **kwargs):
12
+ h_edge_hat = self.decoder(h_src=h_src, h_dst=h_dst)
13
+
14
+ h_edge = torch.cat([h_src, h_dst], dim=-1)
15
+ loss = self.loss_fn(h_edge_hat, h_edge, inference=inference)
16
+ return {"loss": loss}
@@ -0,0 +1,51 @@
1
+ import torch
2
+ import torch.nn as nn
3
+
4
+
5
+ class GMAEFeatReconstruction(nn.Module):
6
+ def __init__(self, decoder, loss_fn, mask_rate, embed_dim):
7
+ super(GMAEFeatReconstruction, self).__init__()
8
+ self.decoder = decoder
9
+ self.loss_fn = loss_fn
10
+ self.mask_rate = mask_rate
11
+ # Learnable mask token initialized to zeros, matching MAGIC-main
12
+ self.mask_token = nn.Parameter(torch.zeros(1, embed_dim))
13
+
14
+ def mask_input(self, x):
15
+ """
16
+ Masks the input features BEFORE encoding.
17
+ Returns:
18
+ x_masked: The input features with masked nodes replaced by token
19
+ mask_nodes: Indices of masked nodes
20
+ """
21
+ num_nodes = x.shape[0]
22
+ num_mask_nodes = int(self.mask_rate * num_nodes)
23
+ perm = torch.randperm(num_nodes, device=x.device)
24
+ mask_nodes = perm[:num_mask_nodes]
25
+
26
+ x_masked = x.clone()
27
+ x_masked[mask_nodes] = self.mask_token.to(x.device)
28
+
29
+ return x_masked, mask_nodes
30
+
31
+ def forward(self, x, h, edge_index, inference, **kwargs):
32
+ # Recover mask_nodes passed from Model.forward
33
+ mask_nodes = kwargs.get("mask_nodes", None)
34
+
35
+ # The reconstruction is a training signal only: MAGIC scores nodes with its k-NN
36
+ # detector, so the decoder is not run at inference
37
+ if inference:
38
+ return {"loss": torch.zeros((x.shape[0],), device=h.device)}
39
+
40
+ if mask_nodes is None:
41
+ raise ValueError(
42
+ "GMAEFeatReconstruction objective requires masked nodes, but mask_nodes is None."
43
+ )
44
+
45
+ batch = kwargs.get("batch")
46
+ edge_feats = getattr(batch, "edge_feats", None) if batch else None
47
+ recon = self.decoder(h, edge_index, edge_feats=edge_feats)
48
+
49
+ # Loss only on the masked nodes
50
+ loss = self.loss_fn(recon[mask_nodes], x[mask_nodes].to(h.device), inference=False)
51
+ return {"loss": loss}
@@ -0,0 +1,13 @@
1
+ import torch.nn as nn
2
+
3
+
4
+ class NodeEmbReconstruction(nn.Module):
5
+ def __init__(self, decoder, loss_fn):
6
+ super(NodeEmbReconstruction, self).__init__()
7
+ self.decoder = decoder
8
+ self.loss_fn = loss_fn
9
+
10
+ def forward(self, h, inference, **kwargs):
11
+ h_hat = self.decoder(h)
12
+ loss = self.loss_fn(h_hat, h, inference=inference)
13
+ return {"loss": loss}
@@ -0,0 +1,13 @@
1
+ import torch.nn as nn
2
+
3
+
4
+ class NodeFeatReconstruction(nn.Module):
5
+ def __init__(self, decoder, loss_fn):
6
+ super(NodeFeatReconstruction, self).__init__()
7
+ self.decoder = decoder
8
+ self.loss_fn = loss_fn
9
+
10
+ def forward(self, h, x, inference, **kwargs):
11
+ x_hat = self.decoder(h)
12
+ loss = self.loss_fn(x_hat, x, inference=inference)
13
+ return {"loss": loss}
@@ -0,0 +1,55 @@
1
+ import torch
2
+ import torch.nn as nn
3
+
4
+ from pidsmaker.utils.utils import log
5
+
6
+
7
+ class ValidationWrapper(nn.Module):
8
+ """
9
+ Binded to a an objective object to store the scores seen in the validation set.
10
+ """
11
+
12
+ def __init__(self, objective, graph_reindexer, is_edge_type_prediction, use_few_shot):
13
+ super().__init__()
14
+ self.objective = objective
15
+ self.graph_reindexer = graph_reindexer
16
+ self.is_edge_type_prediction = is_edge_type_prediction
17
+
18
+ self.use_few_shot = use_few_shot
19
+ self.losses = []
20
+ self.ys = []
21
+
22
+ def get_val_score(self) -> float:
23
+ if self.use_few_shot:
24
+ # Chunks of scores are concatenated once (rather than one 0-d tensor per edge)
25
+ self.losses = torch.cat([l.reshape(-1) for l in self.losses]) if self.losses else torch.tensor([])
26
+ self.ys = torch.cat([y.reshape(-1) for y in self.ys]) if self.ys else torch.tensor([])
27
+ malicious_mean = self.losses[self.ys == 1].mean()
28
+ benign_mean = self.losses[self.ys == 0].mean()
29
+ log(f"=> Total mean score of fake malicious edges: {malicious_mean:.4f}")
30
+ log(f"=> Total mean score of benign malicious edges: {benign_mean:.4f}")
31
+ # ap = ap_score(self.ys, self.losses)
32
+ score = malicious_mean - benign_mean
33
+ elif hasattr(self.objective, "get_val_score"):
34
+ # Objectives measuring their own validation quality (e.g. link prediction AUC + AP)
35
+ score = self.objective.get_val_score()
36
+ else:
37
+ score = 0.0
38
+
39
+ self.losses = []
40
+ self.ys = []
41
+ return score
42
+
43
+ def forward(self, edge_type, y_edge, validation, inference, *args, **kwargs):
44
+ results = self.objective(
45
+ *args, edge_type=edge_type, y_edge=y_edge, inference=inference, validation=validation, **kwargs
46
+ )
47
+ assert isinstance(results, dict), "Return value of an objective should be a dict"
48
+
49
+ loss_or_losses = results["loss"]
50
+
51
+ if validation and self.use_few_shot:
52
+ self.losses.append(loss_or_losses.detach().cpu())
53
+ self.ys.append(y_edge.cpu())
54
+
55
+ return results
File without changes
@@ -0,0 +1 @@
1
+ from . import build_default_graphs, build_magic_graphs