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.
- pidsmaker/__init__.py +1 -0
- pidsmaker/cli.py +81 -0
- pidsmaker/config/__init__.py +2 -0
- pidsmaker/config/config.py +2100 -0
- pidsmaker/config/pipeline.py +1824 -0
- pidsmaker/config/schemas.py +1032 -0
- pidsmaker/datasets.py +323 -0
- pidsmaker/debug_tests.py +30 -0
- pidsmaker/decoders/__init__.py +5 -0
- pidsmaker/decoders/custom_edge_mlp_decoder.py +17 -0
- pidsmaker/decoders/custom_mlp_decoder.py +10 -0
- pidsmaker/decoders/edge_linear_decoder.py +16 -0
- pidsmaker/decoders/inner_product_decoder.py +18 -0
- pidsmaker/decoders/nodlink_decoder.py +56 -0
- pidsmaker/detection/__init__.py +0 -0
- pidsmaker/detection/evaluation_methods/__init__.py +9 -0
- pidsmaker/detection/evaluation_methods/edge_evaluation.py +255 -0
- pidsmaker/detection/evaluation_methods/evaluation_utils.py +1788 -0
- pidsmaker/detection/evaluation_methods/host_two_stage_evaluation.py +115 -0
- pidsmaker/detection/evaluation_methods/node_evaluation.py +459 -0
- pidsmaker/detection/evaluation_methods/node_tw_evaluation.py +196 -0
- pidsmaker/detection/evaluation_methods/plot.py +192 -0
- pidsmaker/detection/evaluation_methods/queue_evaluation.py +456 -0
- pidsmaker/detection/evaluation_methods/tw_evaluation.py +93 -0
- pidsmaker/detection/flash_detection.py +162 -0
- pidsmaker/detection/magic_knn.py +190 -0
- pidsmaker/detection/node_scoring.py +52 -0
- pidsmaker/detection/threatrace_detection.py +65 -0
- pidsmaker/detection/training_methods/__init__.py +1 -0
- pidsmaker/detection/training_methods/inference_loop.py +287 -0
- pidsmaker/detection/training_methods/ocrapt_early_stop.py +165 -0
- pidsmaker/detection/training_methods/threatrace_training.py +168 -0
- pidsmaker/detection/training_methods/training_loop.py +383 -0
- pidsmaker/encoders/__init__.py +22 -0
- pidsmaker/encoders/argus_encoder.py +69 -0
- pidsmaker/encoders/custom_mlp.py +75 -0
- pidsmaker/encoders/custom_mlp_encoder.py +10 -0
- pidsmaker/encoders/egraphsage_encoder.py +56 -0
- pidsmaker/encoders/gat.py +67 -0
- pidsmaker/encoders/gcn.py +27 -0
- pidsmaker/encoders/gin.py +48 -0
- pidsmaker/encoders/glstm.py +298 -0
- pidsmaker/encoders/graph_attention.py +63 -0
- pidsmaker/encoders/gru.py +29 -0
- pidsmaker/encoders/hetero/__init__.py +4 -0
- pidsmaker/encoders/hetero/ancestor_encoder.py +98 -0
- pidsmaker/encoders/hetero/entity_encoder.py +33 -0
- pidsmaker/encoders/hetero/event_encoder.py +81 -0
- pidsmaker/encoders/hetero/hetero_graph_transformer.py +40 -0
- pidsmaker/encoders/lares_encoder.py +68 -0
- pidsmaker/encoders/linear_encoder.py +16 -0
- pidsmaker/encoders/magic_encoder.py +161 -0
- pidsmaker/encoders/rcaid_encoder.py +81 -0
- pidsmaker/encoders/rgcn.py +75 -0
- pidsmaker/encoders/sage.py +51 -0
- pidsmaker/encoders/shadewatcher_encoder.py +149 -0
- pidsmaker/encoders/sum_aggregation.py +20 -0
- pidsmaker/encoders/temporal_wrappers.py +80 -0
- pidsmaker/encoders/textrcnn.py +82 -0
- pidsmaker/encoders/tgn_encoder.py +193 -0
- pidsmaker/experiments/tuning.py +102 -0
- pidsmaker/experiments/uncertainty.py +261 -0
- pidsmaker/factory.py +1456 -0
- pidsmaker/featurization/__init__.py +0 -0
- pidsmaker/featurization/feat_inference_methods/__init__.py +7 -0
- pidsmaker/featurization/feat_inference_methods/feat_inference_HFH.py +30 -0
- pidsmaker/featurization/feat_inference_methods/feat_inference_TRW.py +65 -0
- pidsmaker/featurization/feat_inference_methods/feat_inference_alacarte.py +14 -0
- pidsmaker/featurization/feat_inference_methods/feat_inference_doc2vec.py +53 -0
- pidsmaker/featurization/feat_inference_methods/feat_inference_fasttext.py +37 -0
- pidsmaker/featurization/feat_inference_methods/feat_inference_flash.py +69 -0
- pidsmaker/featurization/feat_inference_methods/feat_inference_graph2vec.py +84 -0
- pidsmaker/featurization/feat_inference_methods/feat_inference_ocrapt_features.py +95 -0
- pidsmaker/featurization/feat_inference_methods/feat_inference_pretrained.py +1728 -0
- pidsmaker/featurization/feat_inference_methods/feat_inference_word2vec.py +55 -0
- pidsmaker/featurization/featurization_methods/__init__.py +0 -0
- pidsmaker/featurization/featurization_methods/build_trw.py +66 -0
- pidsmaker/featurization/featurization_methods/featurization_alacarte.py +747 -0
- pidsmaker/featurization/featurization_methods/featurization_doc2vec.py +98 -0
- pidsmaker/featurization/featurization_methods/featurization_fasttext.py +74 -0
- pidsmaker/featurization/featurization_methods/featurization_flash.py +201 -0
- pidsmaker/featurization/featurization_methods/featurization_graph2vec.py +242 -0
- pidsmaker/featurization/featurization_methods/featurization_trw.py +114 -0
- pidsmaker/featurization/featurization_methods/featurization_word2vec.py +89 -0
- pidsmaker/featurization/featurization_utils.py +275 -0
- pidsmaker/featurization/utils/build_random_walks.py +66 -0
- pidsmaker/featurization/utils/trw.py +203 -0
- pidsmaker/hetero.py +81 -0
- pidsmaker/losses.py +170 -0
- pidsmaker/main.py +478 -0
- pidsmaker/mimicry.py +284 -0
- pidsmaker/model.py +382 -0
- pidsmaker/objectives/__init__.py +16 -0
- pidsmaker/objectives/autoencode_edge_emb.py +43 -0
- pidsmaker/objectives/deep_graph_infomax.py +94 -0
- pidsmaker/objectives/detect_few_shot.py +21 -0
- pidsmaker/objectives/one_class.py +75 -0
- pidsmaker/objectives/predict_edge_contrastive.py +165 -0
- pidsmaker/objectives/predict_edge_supervised.py +77 -0
- pidsmaker/objectives/predict_edge_type.py +28 -0
- pidsmaker/objectives/predict_masked_struct.py +49 -0
- pidsmaker/objectives/predict_node_type.py +36 -0
- pidsmaker/objectives/predict_process_tag.py +169 -0
- pidsmaker/objectives/predict_snapshot_embedding.py +97 -0
- pidsmaker/objectives/reconstruct_edge_emb.py +16 -0
- pidsmaker/objectives/reconstruct_masked_feat.py +51 -0
- pidsmaker/objectives/reconstruct_node_emb.py +13 -0
- pidsmaker/objectives/reconstruct_node_feat.py +13 -0
- pidsmaker/objectives/validation_wrapper.py +55 -0
- pidsmaker/preprocessing/__init__.py +0 -0
- pidsmaker/preprocessing/build_graph_methods/__init__.py +1 -0
- pidsmaker/preprocessing/build_graph_methods/build_default_graphs.py +825 -0
- pidsmaker/preprocessing/build_graph_methods/build_magic_graphs.py +216 -0
- pidsmaker/preprocessing/cleaning.py +258 -0
- pidsmaker/preprocessing/transformation_methods/__init__.py +2 -0
- pidsmaker/preprocessing/transformation_methods/attack_generation/synthetic_attack_naive.py +194 -0
- pidsmaker/preprocessing/transformation_methods/transformation_dag.py +28 -0
- pidsmaker/preprocessing/transformation_methods/transformation_merge_edges.py +136 -0
- pidsmaker/preprocessing/transformation_methods/transformation_rcaid_pseudo_graph.py +510 -0
- pidsmaker/preprocessing/transformation_methods/transformation_undirected.py +24 -0
- pidsmaker/preprocessing/transformation_methods/transformation_utils.py +36 -0
- pidsmaker/pretrained/__init__.py +5 -0
- pidsmaker/pretrained/data/__init__.py +4 -0
- pidsmaker/pretrained/data/behavior_signatures.py +548 -0
- pidsmaker/pretrained/data/canonical_tokens.py +1035 -0
- pidsmaker/pretrained/data/edge_filter.py +381 -0
- pidsmaker/pretrained/data/entity_classes.py +476 -0
- pidsmaker/pretrained/data/sampler.py +926 -0
- pidsmaker/pretrained/data/tokenizer_bpe.py +1659 -0
- pidsmaker/pretrained/detect.py +1427 -0
- pidsmaker/pretrained/embedding_generator.py +252 -0
- pidsmaker/pretrained/finetune.py +1434 -0
- pidsmaker/pretrained/models/__init__.py +20 -0
- pidsmaker/pretrained/models/behavior.py +348 -0
- pidsmaker/pretrained/models/bert.py +286 -0
- pidsmaker/pretrained/models/deepwalk.py +128 -0
- pidsmaker/pretrained/models/dgi.py +120 -0
- pidsmaker/pretrained/models/gae.py +114 -0
- pidsmaker/pretrained/models/gnn_distill.py +475 -0
- pidsmaker/pretrained/models/graphmae.py +373 -0
- pidsmaker/pretrained/models/hf_pretrained.py +213 -0
- pidsmaker/pretrained/models/llama.py +110 -0
- pidsmaker/pretrained/models/modernbert.py +567 -0
- pidsmaker/pretrained/models/roberta.py +147 -0
- pidsmaker/pretrained/models/rope_utils.py +99 -0
- pidsmaker/pretrained/models/ropebert.py +322 -0
- pidsmaker/pretrained/models/spider.py +204 -0
- pidsmaker/pretrained/models/tgn.py +770 -0
- pidsmaker/pretrained/pretrain/__init__.py +3 -0
- pidsmaker/pretrained/pretrain/pretrain_behavior_cluster.py +513 -0
- pidsmaker/pretrained/pretrain/pretrain_common.py +585 -0
- pidsmaker/pretrained/pretrain/pretrain_deepwalk.py +31 -0
- pidsmaker/pretrained/pretrain/pretrain_dgi.py +143 -0
- pidsmaker/pretrained/pretrain/pretrain_gae.py +143 -0
- pidsmaker/pretrained/pretrain/pretrain_gnn_distill.py +438 -0
- pidsmaker/pretrained/pretrain/pretrain_graphmae.py +151 -0
- pidsmaker/pretrained/pretrain/pretrain_hf.py +169 -0
- pidsmaker/pretrained/pretrain/pretrain_main.py +275 -0
- pidsmaker/pretrained/pretrain/pretrain_mlm.py +491 -0
- pidsmaker/pretrained/pretrain/pretrain_spider.py +502 -0
- pidsmaker/pretrained/training_utils.py +157 -0
- pidsmaker/process_reapr_gt.py +101 -0
- pidsmaker/resources/config/anomal_e.yml +25 -0
- pidsmaker/resources/config/argus.yml +56 -0
- pidsmaker/resources/config/attack_edges/cadets_e3.yml +435 -0
- pidsmaker/resources/config/attack_edges/cadets_e5.yml +407 -0
- pidsmaker/resources/config/attack_edges/theia_e3.yml +382 -0
- pidsmaker/resources/config/attack_edges/theia_e5.yml +387 -0
- pidsmaker/resources/config/attack_edges/trace_e3.yml +415 -0
- pidsmaker/resources/config/attack_edges/trace_e5.yml +417 -0
- pidsmaker/resources/config/default.yml +315 -0
- pidsmaker/resources/config/egraphsage.yml +95 -0
- pidsmaker/resources/config/euler.yml +104 -0
- pidsmaker/resources/config/eval/eval_set_clustering.json +3170 -0
- pidsmaker/resources/config/experiments/tuning/components/tuning_featurization_methods.yml +29 -0
- pidsmaker/resources/config/experiments/tuning/systems/clearscope_e5/tuning_orthrus.yml +14 -0
- pidsmaker/resources/config/experiments/tuning/systems/default/tuning_default_baselines.yml +13 -0
- pidsmaker/resources/config/experiments/tuning/systems/default/tuning_orthrus_fixed.yml +16 -0
- pidsmaker/resources/config/experiments/uncertainty/none.yml +5 -0
- pidsmaker/resources/config/experiments/uncertainty/run_n_times.yml +12 -0
- pidsmaker/resources/config/experiments/uncertainty/run_n_times_hyperparameters.yml +12 -0
- pidsmaker/resources/config/experiments/uncertainty/uncertainty.yml +22 -0
- pidsmaker/resources/config/flash.yml +79 -0
- pidsmaker/resources/config/jbeil.yml +65 -0
- pidsmaker/resources/config/kairos.yml +121 -0
- pidsmaker/resources/config/lares.yml +115 -0
- pidsmaker/resources/config/magic.yml +86 -0
- pidsmaker/resources/config/nodlink.yml +79 -0
- pidsmaker/resources/config/ocrapt.yml +91 -0
- pidsmaker/resources/config/orthrus.yml +126 -0
- pidsmaker/resources/config/orthrus_fixed.yml +17 -0
- pidsmaker/resources/config/pretrained/README.md +101 -0
- pidsmaker/resources/config/pretrained/cybergfm/cybergfm.yml +49 -0
- pidsmaker/resources/config/pretrained/pretrained.yml +190 -0
- pidsmaker/resources/config/pretrained/pretrained_flash.yml +9 -0
- pidsmaker/resources/config/pretrained/pretrained_kairos.yml +12 -0
- pidsmaker/resources/config/pretrained/pretrained_magic.yml +1 -0
- pidsmaker/resources/config/pretrained/pretrained_nodlink.yml +1 -0
- pidsmaker/resources/config/pretrained/pretrained_orthrus.yml +1 -0
- pidsmaker/resources/config/pretrained/pretrained_supervised.yml +13 -0
- pidsmaker/resources/config/pretrained/pretrained_threatrace.yml +8 -0
- pidsmaker/resources/config/pretrained/pretrained_velox.yml +14 -0
- pidsmaker/resources/config/prographer.yml +136 -0
- pidsmaker/resources/config/rcaid.yml +88 -0
- pidsmaker/resources/config/shadewatcher.yml +146 -0
- pidsmaker/resources/config/tests.yml +10 -0
- pidsmaker/resources/config/threatrace.yml +73 -0
- pidsmaker/resources/config/tuned_baselines/optc_net/tuned_argus.yml +4 -0
- pidsmaker/resources/config/tuned_baselines/optc_net/tuned_lares.yml +13 -0
- pidsmaker/resources/config/velox.yml +10 -0
- pidsmaker/resources/config/viz_config.yml +10 -0
- pidsmaker/resources/ground_truth/orthrus/E3-CADETS/node_Nginx_Backdoor_06.csv +8 -0
- pidsmaker/resources/ground_truth/orthrus/E3-CADETS/node_Nginx_Backdoor_11.csv +4 -0
- pidsmaker/resources/ground_truth/orthrus/E3-CADETS/node_Nginx_Backdoor_12.csv +43 -0
- pidsmaker/resources/ground_truth/orthrus/E3-CADETS/node_Nginx_Backdoor_13.csv +24 -0
- pidsmaker/resources/ground_truth/orthrus/E3-CLEARSCOPE/node_clearscope_e3_firefox_0411.csv +41 -0
- pidsmaker/resources/ground_truth/orthrus/E3-CLEARSCOPE/node_clearscope_e3_firefox_0412.csv +0 -0
- pidsmaker/resources/ground_truth/orthrus/E3-FIVEDIRECTIONS/node_fivedirections_e3_browser_0412.csv +1 -0
- pidsmaker/resources/ground_truth/orthrus/E3-FIVEDIRECTIONS/node_fivedirections_e3_excel_0409.csv +63 -0
- pidsmaker/resources/ground_truth/orthrus/E3-FIVEDIRECTIONS/node_fivedirections_e3_firefox_0411.csv +56 -0
- pidsmaker/resources/ground_truth/orthrus/E3-THEIA/node_Browser_Extension_Drakon_Dropper.csv +61 -0
- pidsmaker/resources/ground_truth/orthrus/E3-THEIA/node_Firefox_Backdoor_Drakon_In_Memory.csv +58 -0
- pidsmaker/resources/ground_truth/orthrus/E3-TRACE/node_trace_e3_firefox_0410.csv +11 -0
- pidsmaker/resources/ground_truth/orthrus/E3-TRACE/node_trace_e3_phishing_executable_0413.csv +11 -0
- pidsmaker/resources/ground_truth/orthrus/E3-TRACE/node_trace_e3_pine_0413.csv +14 -0
- pidsmaker/resources/ground_truth/orthrus/E5-CADETS/node_Nginx_Drakon_APT.csv +19 -0
- pidsmaker/resources/ground_truth/orthrus/E5-CADETS/node_Nginx_Drakon_APT_17.csv +107 -0
- pidsmaker/resources/ground_truth/orthrus/E5-CLEARSCOPE/node_clearscope_e5_appstarter_0515.csv +26 -0
- pidsmaker/resources/ground_truth/orthrus/E5-CLEARSCOPE/node_clearscope_e5_firefox_0517.csv +1 -0
- pidsmaker/resources/ground_truth/orthrus/E5-CLEARSCOPE/node_clearscope_e5_lockwatch_0517.csv +17 -0
- pidsmaker/resources/ground_truth/orthrus/E5-CLEARSCOPE/node_clearscope_e5_tester_0517.csv +8 -0
- pidsmaker/resources/ground_truth/orthrus/E5-FIVEDIRECTIONS/node_fivedirections_e5_bits_0515.csv +54 -0
- pidsmaker/resources/ground_truth/orthrus/E5-FIVEDIRECTIONS/node_fivedirections_e5_copykatz_0509.csv +87 -0
- pidsmaker/resources/ground_truth/orthrus/E5-FIVEDIRECTIONS/node_fivedirections_e5_dns_0517.csv +11 -0
- pidsmaker/resources/ground_truth/orthrus/E5-FIVEDIRECTIONS/node_fivedirections_e5_drakon_0517.csv +6 -0
- pidsmaker/resources/ground_truth/orthrus/E5-THEIA/node_THEIA_1_Firefox_Drakon_APT_BinFmt_Elevate_Inject.csv +70 -0
- pidsmaker/resources/ground_truth/orthrus/E5-TRACE/node_Trace_Firefox_Drakon.csv +71 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_edr/atlasv2_edr_m1.csv +1 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_edr/atlasv2_edr_m2.csv +1 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_edr/atlasv2_edr_m3.csv +1 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_edr/atlasv2_edr_m4.csv +5 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_edr/atlasv2_edr_m5.csv +23 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_edr/atlasv2_edr_m6.csv +18 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_edr/atlasv2_edr_s1.csv +1 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_edr/atlasv2_edr_s2.csv +1 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_edr/atlasv2_edr_s3.csv +16 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_edr/atlasv2_edr_s4.csv +22 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_h1/node_h1_m1.csv +126 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_h1/node_h1_m2.csv +105 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_h1/node_h1_m3.csv +94 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_h1/node_h1_m4.csv +139 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_h1/node_h1_m5.csv +228 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_h1/node_h1_m6.csv +131 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_h1/node_h1_s1.csv +118 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_h1/node_h1_s2.csv +89 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_h1/node_h1_s3.csv +133 -0
- pidsmaker/resources/ground_truth/orthrus/atlasv2_h1/node_h1_s4.csv +135 -0
- pidsmaker/resources/ground_truth/orthrus/carbanakv2_edr/carbanakv2_edr.csv +2453 -0
- pidsmaker/resources/ground_truth/orthrus/h051/node_h051_0925.csv +114 -0
- pidsmaker/resources/ground_truth/orthrus/h201/node_h201_0923.csv +2905 -0
- pidsmaker/resources/ground_truth/orthrus/h501/node_h501_0924.csv +749 -0
- pidsmaker/resources/ground_truth/orthrus/readme.md +98 -0
- pidsmaker/resources/ground_truth/reapr/E3-CADETS/node_Nginx_Backdoor_06.csv +3 -0
- pidsmaker/resources/ground_truth/reapr/E3-CADETS/node_Nginx_Backdoor_12.csv +655 -0
- pidsmaker/resources/ground_truth/reapr/E3-CADETS/node_Nginx_Backdoor_13.csv +770 -0
- pidsmaker/resources/ground_truth/reapr/E3-FIVEDIRECTIONS/node_fivedirections_e3_excel_0409.csv +0 -0
- pidsmaker/resources/ground_truth/reapr/E3-FIVEDIRECTIONS/node_fivedirections_e3_firefox_0411.csv +18 -0
- pidsmaker/resources/ground_truth/reapr/E3-THEIA/node_Browser_Extension_Drakon_Dropper.csv +42 -0
- pidsmaker/resources/ground_truth/reapr/E3-THEIA/node_Firefox_Backdoor_Drakon_In_Memory.csv +81 -0
- pidsmaker/resources/ground_truth/reapr/E3-TRACE/node_trace_e3_firefox_0410.csv +37 -0
- pidsmaker/resources/ground_truth/reapr/E3-TRACE/node_trace_e3_phishing_executable_0413.csv +9 -0
- pidsmaker/resources/ground_truth/reapr/E3-TRACE/node_trace_e3_pine_0413.csv +40 -0
- pidsmaker/resources/ground_truth/threatrace/E3-CADETS/ground_truth.txt +12858 -0
- pidsmaker/resources/ground_truth/threatrace/E3-FIVEDIRECTIONS/ground_truth.txt +18420 -0
- pidsmaker/resources/ground_truth/threatrace/E3-THEIA/ground_truth.txt +25363 -0
- pidsmaker/resources/ground_truth/threatrace/E3-TRACE/ground_truth.txt +68265 -0
- pidsmaker/resources/ground_truth/threatrace/README.md +123 -0
- pidsmaker/tasks/__init__.py +10 -0
- pidsmaker/tasks/batching.py +47 -0
- pidsmaker/tasks/construction.py +31 -0
- pidsmaker/tasks/evaluation.py +241 -0
- pidsmaker/tasks/feat_inference.py +413 -0
- pidsmaker/tasks/featurization.py +43 -0
- pidsmaker/tasks/training.py +17 -0
- pidsmaker/tasks/transformation.py +306 -0
- pidsmaker/tasks/triage.py +143 -0
- pidsmaker/tgn.py +635 -0
- pidsmaker/tokenization/__init__.py +112 -0
- pidsmaker/tokenization/base.py +58 -0
- pidsmaker/tokenization/bpe_tokenizer.py +83 -0
- pidsmaker/tokenization/hf_tokenizer.py +61 -0
- pidsmaker/tokenization/hierarchical_tokenizer.py +44 -0
- pidsmaker/tokenization/label_tokenizer.py +24 -0
- pidsmaker/tokenization/nltk_tokenizer.py +84 -0
- pidsmaker/tokenization/substitution.py +295 -0
- pidsmaker/triage/__init__.py +0 -0
- pidsmaker/triage/tracing_methods/__init__.py +1 -0
- pidsmaker/triage/tracing_methods/depimpact.py +213 -0
- pidsmaker/triage/tracing_methods/depimpact_utils.py +537 -0
- pidsmaker/triage/tracing_methods/ocrapt_subgraph.py +267 -0
- pidsmaker/utils/__init__.py +0 -0
- pidsmaker/utils/cache_utils.py +256 -0
- pidsmaker/utils/console.py +282 -0
- pidsmaker/utils/data_utils.py +1742 -0
- pidsmaker/utils/database.py +150 -0
- pidsmaker/utils/dataset_utils.py +413 -0
- pidsmaker/utils/dataset_writer.py +570 -0
- pidsmaker/utils/graph_store.py +634 -0
- pidsmaker/utils/labelling.py +445 -0
- pidsmaker/utils/loss_files.py +193 -0
- pidsmaker/utils/process_tags.py +44 -0
- pidsmaker/utils/utils.py +712 -0
- pidsmaker/vizgen/__init__.py +1 -0
- pidsmaker/vizgen/backfill_manifests.py +100 -0
- pidsmaker/vizgen/dimensionality_reduction.py +249 -0
- pidsmaker/vizgen/embed_exporter.py +467 -0
- pidsmaker/vizgen/exporter.py +493 -0
- pidsmaker/vizgen/html_builder.py +936 -0
- pidsmaker/vizgen/web/__init__.py +1 -0
- pidsmaker/vizgen/web/export.py +62 -0
- pidsmaker/vizgen/web/static/css/app.css +250 -0
- pidsmaker/vizgen/web/static/index.html +182 -0
- pidsmaker/vizgen/web/static/js/app.js +627 -0
- pidsmaker/vizgen/web/static/js/campaign.js +123 -0
- pidsmaker/vizgen/web/static/js/data.js +119 -0
- pidsmaker/vizgen/web/static/js/dialogs.js +240 -0
- pidsmaker/vizgen/web/static/js/jobs.js +75 -0
- pidsmaker/vizgen/web/static/js/scene.js +651 -0
- pidsmaker/vizgen/web/static/js/ui.js +370 -0
- pidsmaker/vizgen/web/static/vendor/OrbitControls.js +1045 -0
- pidsmaker/vizgen/web/static/vendor/d3.v4.min.js +2 -0
- pidsmaker/vizgen/web/static/vendor/three.min.js +6 -0
- pidsmaker/vizgen/web/viz_server.py +2176 -0
- pidsmaker-5.0.0.dist-info/METADATA +597 -0
- pidsmaker-5.0.0.dist-info/RECORD +339 -0
- pidsmaker-5.0.0.dist-info/WHEEL +5 -0
- pidsmaker-5.0.0.dist-info/entry_points.txt +2 -0
- pidsmaker-5.0.0.dist-info/licenses/LICENSE +201 -0
- pidsmaker-5.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Backfill viz_manifest.json for eval runs that predate manifest writing.
|
|
3
|
+
|
|
4
|
+
The Run Browser only lists a run if its eval dir has a viz_manifest.json (or
|
|
5
|
+
viz/*_points.json). New evaluations write the manifest automatically; older runs
|
|
6
|
+
have none, so they stay hidden. This calls the pipeline's own write_viz_manifest
|
|
7
|
+
on each completed run that lacks one -- it only indexes artifacts already on disk,
|
|
8
|
+
nothing is retrained. Idempotent (skips existing unless --force).
|
|
9
|
+
|
|
10
|
+
Usage:
|
|
11
|
+
python -m pidsmaker.vizgen.backfill_manifests [--dry-run] [--force] [--artifacts-root PATH]
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
import argparse
|
|
15
|
+
import glob
|
|
16
|
+
import os
|
|
17
|
+
import sys
|
|
18
|
+
|
|
19
|
+
from pidsmaker.config.pipeline import (
|
|
20
|
+
TASK_FINISHED_FILE,
|
|
21
|
+
VIZ_MANIFEST_FILE,
|
|
22
|
+
write_viz_manifest,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def resolve_artifacts_root(override=None):
|
|
27
|
+
"""Mirror viz_server.get_artifacts_root so we scan what the server reads."""
|
|
28
|
+
if override:
|
|
29
|
+
return override
|
|
30
|
+
if os.path.isdir("/home/artifacts"):
|
|
31
|
+
return "/home/artifacts"
|
|
32
|
+
repo_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
33
|
+
return os.environ.get("PIDS_ARTIFACTS_DIR", os.path.join(repo_root, "artifacts"))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def find_eval_runs(artifacts_root):
|
|
37
|
+
"""Same patterns the Run Browser discovers from."""
|
|
38
|
+
patterns = [
|
|
39
|
+
os.path.join(artifacts_root, "evaluation/evaluation/*/*"),
|
|
40
|
+
os.path.join(artifacts_root, "detection/evaluation/*/*"),
|
|
41
|
+
]
|
|
42
|
+
runs = []
|
|
43
|
+
for pat in patterns:
|
|
44
|
+
runs.extend(d for d in glob.glob(pat) if os.path.isdir(d))
|
|
45
|
+
return sorted(set(runs))
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def main():
|
|
49
|
+
ap = argparse.ArgumentParser(description=__doc__,
|
|
50
|
+
formatter_class=argparse.RawDescriptionHelpFormatter)
|
|
51
|
+
ap.add_argument("--artifacts-root", default=None,
|
|
52
|
+
help="Override the artifacts root (defaults to the server's resolution).")
|
|
53
|
+
ap.add_argument("--dry-run", action="store_true",
|
|
54
|
+
help="Report what would be written without writing anything.")
|
|
55
|
+
ap.add_argument("--force", action="store_true",
|
|
56
|
+
help="Rewrite manifests that already exist.")
|
|
57
|
+
args = ap.parse_args()
|
|
58
|
+
|
|
59
|
+
root = resolve_artifacts_root(args.artifacts_root)
|
|
60
|
+
if not os.path.isdir(root):
|
|
61
|
+
print(f"ERROR: artifacts root does not exist: {root}", file=sys.stderr)
|
|
62
|
+
return 1
|
|
63
|
+
print(f"[backfill] artifacts root: {root}")
|
|
64
|
+
|
|
65
|
+
runs = find_eval_runs(root)
|
|
66
|
+
print(f"[backfill] found {len(runs)} eval run dir(s)")
|
|
67
|
+
|
|
68
|
+
written = skipped_have = skipped_incomplete = 0
|
|
69
|
+
for d in runs:
|
|
70
|
+
has_manifest = os.path.exists(os.path.join(d, VIZ_MANIFEST_FILE))
|
|
71
|
+
completed = os.path.exists(os.path.join(d, TASK_FINISHED_FILE))
|
|
72
|
+
has_pr = os.path.isdir(os.path.join(d, "precision_recall_dir"))
|
|
73
|
+
|
|
74
|
+
if has_manifest and not args.force:
|
|
75
|
+
skipped_have += 1
|
|
76
|
+
continue
|
|
77
|
+
# write_viz_manifest no-ops without a precision_recall_dir; report it here
|
|
78
|
+
# so incomplete runs are visibly distinguished from backfilled ones.
|
|
79
|
+
if not has_pr:
|
|
80
|
+
skipped_incomplete += 1
|
|
81
|
+
print(f" SKIP (no precision_recall_dir, completed={completed}): {d}")
|
|
82
|
+
continue
|
|
83
|
+
|
|
84
|
+
if args.dry_run:
|
|
85
|
+
print(f" WOULD WRITE: {os.path.join(d, VIZ_MANIFEST_FILE)}")
|
|
86
|
+
written += 1
|
|
87
|
+
continue
|
|
88
|
+
|
|
89
|
+
write_viz_manifest(d)
|
|
90
|
+
written += 1
|
|
91
|
+
|
|
92
|
+
verb = "would write" if args.dry_run else "wrote"
|
|
93
|
+
print(f"\n[backfill] {verb} {written} manifest(s); "
|
|
94
|
+
f"{skipped_have} already had one; "
|
|
95
|
+
f"{skipped_incomplete} skipped (incomplete, no precision_recall_dir)")
|
|
96
|
+
return 0
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
if __name__ == "__main__":
|
|
100
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
"""Dimensionality reduction for temporal 3D embedding visualization.
|
|
2
|
+
|
|
3
|
+
Supports GPU-accelerated UMAP via:
|
|
4
|
+
1. RAPIDS cuML (if installed) — full GPU UMAP
|
|
5
|
+
2. PyTorch GPU kNN + CPU UMAP optimization — hybrid approach
|
|
6
|
+
3. Pure CPU fallback
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import time
|
|
10
|
+
|
|
11
|
+
import numpy as np
|
|
12
|
+
|
|
13
|
+
from pidsmaker.utils.utils import log
|
|
14
|
+
from pidsmaker.vizgen.embed_exporter import ExtractionResult
|
|
15
|
+
|
|
16
|
+
# Globals for interactive Viz Studio overrides
|
|
17
|
+
GLOBAL_N_NEIGHBORS = None
|
|
18
|
+
GLOBAL_MIN_DIST = None
|
|
19
|
+
PROGRESS_CALLBACK = None
|
|
20
|
+
|
|
21
|
+
def _report_progress(msg):
|
|
22
|
+
if PROGRESS_CALLBACK:
|
|
23
|
+
PROGRESS_CALLBACK(msg)
|
|
24
|
+
log(msg)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def reduce_to_3d(result, method="umap", device=None):
|
|
28
|
+
"""Project embeddings to 3D via dimensionality reduction.
|
|
29
|
+
|
|
30
|
+
Deduplicates identical embedding vectors before running UMAP for massive
|
|
31
|
+
speedup and cleaner cluster structure (provenance datasets often have
|
|
32
|
+
hundreds of thousands of nodes sharing the same Word2Vec embedding).
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
result: ExtractionResult with embeddings
|
|
36
|
+
method: 'umap' or 'tsne'
|
|
37
|
+
device: torch device string (e.g. 'cuda:0') for GPU acceleration
|
|
38
|
+
"""
|
|
39
|
+
embeddings = result.embeddings
|
|
40
|
+
if not embeddings:
|
|
41
|
+
raise ValueError("No embeddings to reduce.")
|
|
42
|
+
|
|
43
|
+
num_hops = len(embeddings[0].embedding_hops) if hasattr(embeddings[0], 'embedding_hops') and embeddings[0].embedding_hops else 1
|
|
44
|
+
coords_3d_hops = []
|
|
45
|
+
|
|
46
|
+
for hop_idx in range(num_hops):
|
|
47
|
+
if num_hops > 1:
|
|
48
|
+
log(f"--- Running UMAP for Hop {hop_idx}/{num_hops-1} ---")
|
|
49
|
+
|
|
50
|
+
if hasattr(embeddings[0], 'embedding_hops') and embeddings[0].embedding_hops:
|
|
51
|
+
X = np.stack([e.embedding_hops[hop_idx] for e in embeddings], axis=0).astype(np.float32)
|
|
52
|
+
else:
|
|
53
|
+
X = np.stack([e.embedding for e in embeddings], axis=0).astype(np.float32)
|
|
54
|
+
|
|
55
|
+
n_samples, n_features = X.shape
|
|
56
|
+
if hop_idx == 0:
|
|
57
|
+
log(f"[dim_reduction] Reducing {n_samples} embeddings ({n_features}D) via {method}...")
|
|
58
|
+
|
|
59
|
+
# Dedup identical (to 6 dp) vectors so UMAP only reduces the unique set.
|
|
60
|
+
# View each row as one opaque bytes element and run a 1-D unique — far
|
|
61
|
+
# faster than np.unique(axis=0)'s per-element lexicographic sort on wide
|
|
62
|
+
# (128-D) vectors (~11x on 643k rows), with the same result.
|
|
63
|
+
X_rounded = np.ascontiguousarray(np.round(X, decimals=6))
|
|
64
|
+
row_view = X_rounded.view(
|
|
65
|
+
np.dtype((np.void, X_rounded.dtype.itemsize * X_rounded.shape[1]))
|
|
66
|
+
).reshape(-1)
|
|
67
|
+
_, unique_idx, inverse_idx = np.unique(
|
|
68
|
+
row_view, return_index=True, return_inverse=True
|
|
69
|
+
)
|
|
70
|
+
X_unique = X[unique_idx]
|
|
71
|
+
n_unique = len(X_unique)
|
|
72
|
+
|
|
73
|
+
if hop_idx == 0:
|
|
74
|
+
log(f"[dim_reduction] Deduplicated: {n_samples} -> {n_unique} unique vectors")
|
|
75
|
+
|
|
76
|
+
std = X_unique.std(axis=0)
|
|
77
|
+
constant_mask = std < 1e-8
|
|
78
|
+
if constant_mask.all():
|
|
79
|
+
log("[dim_reduction] WARNING: All features are constant. Using random projection.")
|
|
80
|
+
np.random.seed(42 + hop_idx)
|
|
81
|
+
coords_unique = np.random.randn(n_unique, 3).astype(np.float32) * 0.01
|
|
82
|
+
elif constant_mask.any():
|
|
83
|
+
coords_unique = _run_reduction(X_unique[:, ~constant_mask], method, n_unique, device)
|
|
84
|
+
else:
|
|
85
|
+
coords_unique = _run_reduction(X_unique, method, n_unique, device)
|
|
86
|
+
|
|
87
|
+
coords_3d = coords_unique[inverse_idx]
|
|
88
|
+
|
|
89
|
+
np.random.seed(42 + hop_idx)
|
|
90
|
+
jitter_scale = np.std(coords_unique, axis=0) * 0.02
|
|
91
|
+
jitter = np.random.randn(n_samples, 3).astype(np.float32) * jitter_scale
|
|
92
|
+
coords_3d = coords_3d + jitter
|
|
93
|
+
coords_3d -= coords_3d.mean(axis=0)
|
|
94
|
+
coords_3d_hops.append(coords_3d)
|
|
95
|
+
|
|
96
|
+
points = []
|
|
97
|
+
for i, emb in enumerate(embeddings):
|
|
98
|
+
points.append({
|
|
99
|
+
"node_id": int(emb.node_id),
|
|
100
|
+
"coords_hops": [[float(coords_3d_hops[h][i, 0]), float(coords_3d_hops[h][i, 1]), float(coords_3d_hops[h][i, 2])] for h in range(num_hops)],
|
|
101
|
+
"tw_idx": int(emb.time_window_idx),
|
|
102
|
+
"tw_label": emb.time_window_label,
|
|
103
|
+
"label": int(emb.label),
|
|
104
|
+
"detection_status": int(emb.detection_status),
|
|
105
|
+
"anomaly_score": float(getattr(emb, 'anomaly_score', 0.0)),
|
|
106
|
+
"top_edge": getattr(emb, 'top_edge', ""),
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
log(f"[dim_reduction] Reduced to {len(points)} 3D points across {num_hops} hops.")
|
|
110
|
+
return points
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def _gpu_knn(X, n_neighbors, device_str):
|
|
114
|
+
"""Compute exact k-nearest neighbors on GPU using PyTorch batched cdist.
|
|
115
|
+
|
|
116
|
+
For 640K × 128D, the full distance matrix would be ~1.5TB.
|
|
117
|
+
We batch it to fit in GPU memory (~24GB on RTX 3090).
|
|
118
|
+
"""
|
|
119
|
+
import torch
|
|
120
|
+
|
|
121
|
+
device = torch.device(device_str)
|
|
122
|
+
X_gpu = torch.from_numpy(X).to(device)
|
|
123
|
+
n = X_gpu.shape[0]
|
|
124
|
+
k = n_neighbors
|
|
125
|
+
|
|
126
|
+
# Determine batch size based on available GPU memory
|
|
127
|
+
free_mem = torch.cuda.get_device_properties(device).total_memory
|
|
128
|
+
# Each row of distance matrix: n * 4 bytes (float32)
|
|
129
|
+
# We want batch_size * n * 4 < 20% of GPU mem to be safe, capped at 1000
|
|
130
|
+
batch_size = max(1, int(0.2 * free_mem / (n * 4)))
|
|
131
|
+
batch_size = min(batch_size, 1000, n)
|
|
132
|
+
|
|
133
|
+
_report_progress(f"GPU kNN: {n} points, k={k}, batch_size={batch_size}")
|
|
134
|
+
|
|
135
|
+
knn_indices = np.empty((n, k), dtype=np.int64)
|
|
136
|
+
knn_dists = np.empty((n, k), dtype=np.float32)
|
|
137
|
+
|
|
138
|
+
from tqdm import tqdm
|
|
139
|
+
|
|
140
|
+
t0 = time.time()
|
|
141
|
+
for start in tqdm(range(0, n, batch_size), desc="GPU kNN"):
|
|
142
|
+
end = min(start + batch_size, n)
|
|
143
|
+
# Compute pairwise distances for this batch
|
|
144
|
+
dists = torch.cdist(X_gpu[start:end], X_gpu) # (batch, n)
|
|
145
|
+
|
|
146
|
+
# Vectorized self-distance masking (avoids launching thousands of micro-kernels)
|
|
147
|
+
idx = torch.arange(end - start, device=dists.device)
|
|
148
|
+
dists[idx, start + idx] = float('inf')
|
|
149
|
+
|
|
150
|
+
# Get top-k nearest
|
|
151
|
+
topk_dists, topk_idx = dists.topk(k, largest=False)
|
|
152
|
+
knn_indices[start:end] = topk_idx.cpu().numpy()
|
|
153
|
+
knn_dists[start:end] = topk_dists.cpu().numpy()
|
|
154
|
+
|
|
155
|
+
elapsed = time.time() - t0
|
|
156
|
+
_report_progress(f"GPU kNN completed in {elapsed:.1f}s")
|
|
157
|
+
|
|
158
|
+
del X_gpu
|
|
159
|
+
torch.cuda.empty_cache()
|
|
160
|
+
|
|
161
|
+
return knn_indices, knn_dists
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def _run_reduction(X, method, n_samples, device=None):
|
|
165
|
+
import warnings
|
|
166
|
+
warnings.filterwarnings('ignore', category=UserWarning)
|
|
167
|
+
|
|
168
|
+
if method == "umap":
|
|
169
|
+
n_neighbors = GLOBAL_N_NEIGHBORS if GLOBAL_N_NEIGHBORS else min(30, n_samples - 1)
|
|
170
|
+
min_dist = GLOBAL_MIN_DIST if GLOBAL_MIN_DIST else 0.5
|
|
171
|
+
|
|
172
|
+
# Strategy 1: Try RAPIDS cuML (full GPU UMAP)
|
|
173
|
+
try:
|
|
174
|
+
from cuml.manifold import UMAP as cuUMAP
|
|
175
|
+
_report_progress("Using RAPIDS cuML GPU UMAP")
|
|
176
|
+
t0 = time.time()
|
|
177
|
+
reducer = cuUMAP(
|
|
178
|
+
n_components=3, n_neighbors=n_neighbors, min_dist=min_dist,
|
|
179
|
+
spread=3.0, random_state=42, init='spectral',
|
|
180
|
+
)
|
|
181
|
+
result = reducer.fit_transform(X)
|
|
182
|
+
_report_progress(f"cuML GPU UMAP completed in {time.time()-t0:.1f}s")
|
|
183
|
+
return np.asarray(result)
|
|
184
|
+
except ImportError:
|
|
185
|
+
pass
|
|
186
|
+
except Exception as e:
|
|
187
|
+
# cuML installed but unusable at runtime; fall back instead of crashing.
|
|
188
|
+
_report_progress(f"RAPIDS cuML GPU UMAP unavailable ({type(e).__name__}: {e}); "
|
|
189
|
+
f"falling back to CPU-capable UMAP")
|
|
190
|
+
|
|
191
|
+
# Strategy 2: GPU kNN precomputation + CPU UMAP optimization
|
|
192
|
+
try:
|
|
193
|
+
import umap
|
|
194
|
+
except ImportError:
|
|
195
|
+
raise ImportError("umap-learn is required. Install with: pip install umap-learn")
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
use_gpu_knn = False
|
|
200
|
+
if device and 'cuda' in str(device):
|
|
201
|
+
try:
|
|
202
|
+
import torch
|
|
203
|
+
if torch.cuda.is_available():
|
|
204
|
+
use_gpu_knn = True
|
|
205
|
+
except ImportError:
|
|
206
|
+
pass
|
|
207
|
+
|
|
208
|
+
if use_gpu_knn and n_samples > 10000:
|
|
209
|
+
_report_progress(f"Step 1/2: GPU kNN search ({n_samples} points)...")
|
|
210
|
+
t0 = time.time()
|
|
211
|
+
|
|
212
|
+
knn_indices, knn_dists = _gpu_knn(X, n_neighbors, str(device))
|
|
213
|
+
|
|
214
|
+
_report_progress(f"Step 2/2: CPU UMAP optimization (kNN precomputed)...")
|
|
215
|
+
# Feed precomputed kNN into UMAP — skips the expensive NN search
|
|
216
|
+
reducer = umap.UMAP(
|
|
217
|
+
n_components=3, n_neighbors=n_neighbors, min_dist=min_dist,
|
|
218
|
+
metric="euclidean", random_state=42,
|
|
219
|
+
precomputed_knn=(knn_indices, knn_dists, None),
|
|
220
|
+
n_epochs=200, # Reduce from 500 default for large data
|
|
221
|
+
verbose=True, # Enabled tqdm progress bar
|
|
222
|
+
)
|
|
223
|
+
result = reducer.fit_transform(X)
|
|
224
|
+
_report_progress(f"GPU-hybrid UMAP completed in {time.time()-t0:.1f}s total")
|
|
225
|
+
return result
|
|
226
|
+
else:
|
|
227
|
+
# Strategy 3: Pure CPU fallback
|
|
228
|
+
if n_samples > 100000:
|
|
229
|
+
_report_progress(f"WARNING: Running UMAP on {n_samples} points on CPU. This may take hours.")
|
|
230
|
+
t0 = time.time()
|
|
231
|
+
reducer = umap.UMAP(
|
|
232
|
+
n_components=3, n_neighbors=n_neighbors, min_dist=min_dist,
|
|
233
|
+
metric="euclidean", random_state=42,
|
|
234
|
+
verbose=True,
|
|
235
|
+
)
|
|
236
|
+
result = reducer.fit_transform(X)
|
|
237
|
+
_report_progress(f"CPU UMAP completed in {time.time()-t0:.1f}s")
|
|
238
|
+
return result
|
|
239
|
+
|
|
240
|
+
elif method == "tsne":
|
|
241
|
+
from sklearn.manifold import TSNE
|
|
242
|
+
perplexity = min(30, max(5, n_samples // 4))
|
|
243
|
+
reducer = TSNE(
|
|
244
|
+
n_components=3, perplexity=perplexity, random_state=42,
|
|
245
|
+
init="pca" if X.shape[1] >= 3 else "random", learning_rate="auto",
|
|
246
|
+
)
|
|
247
|
+
return reducer.fit_transform(X)
|
|
248
|
+
else:
|
|
249
|
+
raise ValueError(f"Unknown reduction method: {method!r}. Use 'umap' or 'tsne'.")
|