misp-modules 3.0.8__tar.gz → 3.0.9__tar.gz

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 (237) hide show
  1. {misp_modules-3.0.8 → misp_modules-3.0.9}/PKG-INFO +11 -1
  2. {misp_modules-3.0.8 → misp_modules-3.0.9}/README.md +8 -0
  3. misp_modules-3.0.9/misp_modules/modules/expansion/_rstcloud/__init__.py +19 -0
  4. misp_modules-3.0.9/misp_modules/modules/expansion/_rstcloud/client.py +528 -0
  5. misp_modules-3.0.9/misp_modules/modules/expansion/flowtriq.py +302 -0
  6. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/html_to_markdown.py +7 -2
  7. misp_modules-3.0.9/misp_modules/modules/expansion/rdap.py +172 -0
  8. misp_modules-3.0.9/misp_modules/modules/expansion/rst_cs_beacon.py +165 -0
  9. misp_modules-3.0.9/misp_modules/modules/expansion/rst_favicon.py +169 -0
  10. misp_modules-3.0.9/misp_modules/modules/expansion/rst_html.py +158 -0
  11. misp_modules-3.0.9/misp_modules/modules/expansion/rst_ioc.py +449 -0
  12. misp_modules-3.0.9/misp_modules/modules/expansion/rst_noise_control.py +253 -0
  13. misp_modules-3.0.9/misp_modules/modules/expansion/rst_screenshot.py +144 -0
  14. misp_modules-3.0.9/misp_modules/modules/expansion/rst_ssl.py +134 -0
  15. misp_modules-3.0.9/misp_modules/modules/expansion/rst_whois.py +155 -0
  16. misp_modules-3.0.9/misp_modules/modules/expansion/xposedornot.py +216 -0
  17. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/import_mod/email_import.py +38 -4
  18. {misp_modules-3.0.8 → misp_modules-3.0.9}/pyproject.toml +3 -1
  19. {misp_modules-3.0.8 → misp_modules-3.0.9}/LICENSE +0 -0
  20. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/__init__.py +0 -0
  21. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/__main__.py +0 -0
  22. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/lib/ODTReader/LICENSE +0 -0
  23. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/lib/ODTReader/__init__.py +0 -0
  24. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/lib/ODTReader/odtreader.py +0 -0
  25. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/lib/ODTReader/win32_unicode_argv.py +0 -0
  26. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/lib/__init__.py +0 -0
  27. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/lib/_vmray/__init__.py +0 -0
  28. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/lib/_vmray/parser.py +0 -0
  29. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/lib/_vmray/rest_api.py +0 -0
  30. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/lib/anyrun_sandbox/__init__.py +0 -0
  31. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/lib/anyrun_sandbox/config.py +0 -0
  32. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/lib/anyrun_sandbox/parser.py +0 -0
  33. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/lib/anyrun_sandbox/submitter.py +0 -0
  34. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/lib/cof2misp/LICENSE-2.0.txt +0 -0
  35. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/lib/cof2misp/__init__.py +0 -0
  36. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/lib/cof2misp/cof.py +0 -0
  37. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/lib/dnstrails/LICENSE +0 -0
  38. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/lib/dnstrails/__init__.py +0 -0
  39. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/lib/dnstrails/api.py +0 -0
  40. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/lib/dnstrails/exception.py +0 -0
  41. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/lib/joe_mapping.py +0 -0
  42. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/lib/joe_parser.py +0 -0
  43. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/lib/lastline_api.py +0 -0
  44. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/lib/onyphe/LICENSE +0 -0
  45. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/lib/onyphe/__init__.py +0 -0
  46. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/lib/onyphe/client.py +0 -0
  47. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/lib/onyphe/exception.py +0 -0
  48. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/lib/qintel_helper.py +0 -0
  49. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/lib/synonymsToTagNames.json +0 -0
  50. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/lib/vt_graph_parser/__init__.py +0 -0
  51. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/lib/vt_graph_parser/errors.py +0 -0
  52. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/lib/vt_graph_parser/helpers/__init__.py +0 -0
  53. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/lib/vt_graph_parser/helpers/parsers.py +0 -0
  54. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/lib/vt_graph_parser/helpers/rules.py +0 -0
  55. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/lib/vt_graph_parser/helpers/wrappers.py +0 -0
  56. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/lib/vt_graph_parser/importers/__init__.py +0 -0
  57. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/lib/vt_graph_parser/importers/base.py +0 -0
  58. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/lib/vt_graph_parser/importers/pymisp_response.py +0 -0
  59. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/__init__.py +0 -0
  60. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/action_mod/__init__.py +0 -0
  61. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/action_mod/_utils/__init__.py +0 -0
  62. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/action_mod/_utils/utils.py +0 -0
  63. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/action_mod/export_sentinel.py +0 -0
  64. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/action_mod/mattermost.py +0 -0
  65. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/action_mod/nextcloud_talk.py +0 -0
  66. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/action_mod/slack.py +0 -0
  67. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/action_mod/testaction.py +0 -0
  68. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/__init__.py +0 -0
  69. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/_assemblyline_api.py +0 -0
  70. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/_dnsdb_query/COPYRIGHT +0 -0
  71. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/_dnsdb_query/LICENSE +0 -0
  72. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/_dnsdb_query/README.md +0 -0
  73. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/_dnsdb_query/__init__.py +0 -0
  74. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/_dnsdb_query/dnsdb_query.py +0 -0
  75. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/_ransomcoindb/__init__.py +0 -0
  76. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/_ransomcoindb/ransomcoindb.py +0 -0
  77. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/_vulnerability_parser/__init__.py +0 -0
  78. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/_vulnerability_parser/vulnerability_parser.py +0 -0
  79. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/abuseipdb.py +0 -0
  80. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/alphaMountain.py +0 -0
  81. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/anyrun_sandbox_submit.py +0 -0
  82. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/apiosintds.py +0 -0
  83. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/apivoid.py +0 -0
  84. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/assemblyline_query.py +0 -0
  85. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/assemblyline_submit.py +0 -0
  86. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/backscatter_io.py +0 -0
  87. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/btc_scam_check.py +0 -0
  88. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/btc_steroids.py +0 -0
  89. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/censys_enrich.py +0 -0
  90. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/circl_passivedns.py +0 -0
  91. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/circl_passivessl.py +0 -0
  92. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/clamav.py +0 -0
  93. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/cluster25_expand.py +0 -0
  94. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/convert_markdown_to_pdf.py +0 -0
  95. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/countrycode.py +0 -0
  96. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/cpe.py +0 -0
  97. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/crowdsec.py +0 -0
  98. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/crowdstrike_falcon.py +0 -0
  99. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/cuckoo_submit.py +0 -0
  100. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/cve.py +0 -0
  101. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/cve_advanced.py +0 -0
  102. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/cytomic_orion.py +0 -0
  103. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/dbl_spamhaus.py +0 -0
  104. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/dns.py +0 -0
  105. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/docx_enrich.py +0 -0
  106. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/domaintools.py +0 -0
  107. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/email_security_check.py +0 -0
  108. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/eql.py +0 -0
  109. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/eupi.py +0 -0
  110. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/extract_url_components.py +0 -0
  111. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/farsight_passivedns.py +0 -0
  112. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/geoip_asn.py +0 -0
  113. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/geoip_city.py +0 -0
  114. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/geoip_country.py +0 -0
  115. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/google_safe_browsing.py +0 -0
  116. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/google_threat_intelligence.py +0 -0
  117. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/greynoise.py +0 -0
  118. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/hashdd.py +0 -0
  119. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/hashlookup.py +0 -0
  120. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/hibp.py +0 -0
  121. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/hyasinsight.py +0 -0
  122. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/intel471.py +0 -0
  123. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/intelmq_eventdb.py.experimental +0 -0
  124. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/ip2locationio.py +0 -0
  125. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/ipasn.py +0 -0
  126. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/ipinfo.py +0 -0
  127. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/ipqs_fraud_and_risk_scoring.py +0 -0
  128. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/iprep.py +0 -0
  129. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/jinja_template_rendering.py +0 -0
  130. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/joesandbox_query.py +0 -0
  131. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/joesandbox_submit.py +0 -0
  132. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/lastline_query.py +0 -0
  133. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/lastline_submit.py +0 -0
  134. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/macaddress_io.py +0 -0
  135. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/macvendors.py +0 -0
  136. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/malshare_upload.py +0 -0
  137. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/malwarebazaar.py +0 -0
  138. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/mcafee_insights_enrich.py +0 -0
  139. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/mmdb_lookup.py +0 -0
  140. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/module.py.skeleton +0 -0
  141. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/module_misp_standard.py.skeleton +0 -0
  142. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/mwdb.py +0 -0
  143. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/ocr_enrich.py +0 -0
  144. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/ods_enrich.py +0 -0
  145. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/odt_enrich.py +0 -0
  146. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/onion_lookup.py +0 -0
  147. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/onyphe.py +0 -0
  148. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/onyphe_full.py +0 -0
  149. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/otx.py +0 -0
  150. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/passive_ssh.py +0 -0
  151. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/passivetotal.py +0 -0
  152. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/pdf_enrich.py +0 -0
  153. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/pptx_enrich.py +0 -0
  154. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/qintel_qsentry.py +0 -0
  155. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/qrcode.py +0 -0
  156. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/ransomcoindb.py +0 -0
  157. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/ransomlook.py +0 -0
  158. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/rapid7_attackerkb.py +0 -0
  159. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/rbl.py +0 -0
  160. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/recordedfuture.py +0 -0
  161. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/reversedns.py +0 -0
  162. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/reversinglabs_spectra_analyze.py +0 -0
  163. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/securitytrails.py +0 -0
  164. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/shodan.py +0 -0
  165. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/sigma_queries.py +0 -0
  166. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/sigma_syntax_validator.py +0 -0
  167. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/sigmf_expand.py +0 -0
  168. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/socialscan.py +0 -0
  169. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/socradar_lookup.py +0 -0
  170. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/sophoslabs_intelix.py +0 -0
  171. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/sourcecache.py +0 -0
  172. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/ssh_fingerprint.py +0 -0
  173. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/stairwell.py +0 -0
  174. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/stix2_pattern_syntax_validator.py +0 -0
  175. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/threatcrowd.py +0 -0
  176. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/threatfox.py +0 -0
  177. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/threatminer.py +0 -0
  178. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/tls_certificate_check.py +0 -0
  179. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/triage_submit.py +0 -0
  180. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/trustar_enrich.py +0 -0
  181. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/urlhaus.py +0 -0
  182. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/urlscan.py +0 -0
  183. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/validin.py +0 -0
  184. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/variotdbs.py +0 -0
  185. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/virustotal.py +0 -0
  186. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/virustotal_public.py +0 -0
  187. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/virustotal_upload.py +0 -0
  188. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/vmray_submit.py +0 -0
  189. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/vmware_nsx.py +0 -0
  190. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/vulndb.py +0 -0
  191. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/vulnerability_lookup.py +0 -0
  192. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/vulners.py +0 -0
  193. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/vysion.py +0 -0
  194. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/whois.py +0 -0
  195. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/whoisfreaks.py +0 -0
  196. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/wiki.py +0 -0
  197. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/xforceexchange.py +0 -0
  198. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/xlsx_enrich.py +0 -0
  199. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/yara_query.py +0 -0
  200. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/yara_syntax_validator.py +0 -0
  201. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/expansion/yeti.py +0 -0
  202. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/export_mod/__init__.py +0 -0
  203. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/export_mod/cef_export.py +0 -0
  204. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/export_mod/cisco_firesight_manager_ACL_rule_export.py +0 -0
  205. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/export_mod/defender_endpoint_export.py +0 -0
  206. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/export_mod/goamlexport.py +0 -0
  207. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/export_mod/liteexport.py +0 -0
  208. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/export_mod/mass_eql_export.py +0 -0
  209. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/export_mod/nexthinkexport.py +0 -0
  210. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/export_mod/osqueryexport.py +0 -0
  211. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/export_mod/pdfexport.py +0 -0
  212. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/export_mod/testexport.py +0 -0
  213. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/export_mod/threatStream_misp_export.py +0 -0
  214. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/export_mod/threat_connect_export.py +0 -0
  215. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/export_mod/virustotal_collections.py +0 -0
  216. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/export_mod/vt_graph.py +0 -0
  217. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/export_mod/yara_export.py +0 -0
  218. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/import_mod/__init__.py +0 -0
  219. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/import_mod/anyrun_sandbox_import.py +0 -0
  220. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/import_mod/cof2misp.py +0 -0
  221. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/import_mod/csvimport.py +0 -0
  222. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/import_mod/cuckooimport.py +0 -0
  223. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/import_mod/goamlimport.py +0 -0
  224. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/import_mod/import_blueprint.py +0 -0
  225. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/import_mod/joe_import.py +0 -0
  226. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/import_mod/lastline_import.py +0 -0
  227. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/import_mod/mispjson.py +0 -0
  228. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/import_mod/ocr.py +0 -0
  229. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/import_mod/openiocimport.py +0 -0
  230. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/import_mod/socradar_taxii_feed.py +0 -0
  231. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/import_mod/taxii21.py +0 -0
  232. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/import_mod/testimport.py +0 -0
  233. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/import_mod/threatanalyzer_import.py +0 -0
  234. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/import_mod/url_import.py +0 -0
  235. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/import_mod/vmray_import.py +0 -0
  236. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/modules/import_mod/vmray_summary_json_import.py +0 -0
  237. {misp_modules-3.0.8 → misp_modules-3.0.9}/misp_modules/openapi.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: misp-modules
3
- Version: 3.0.8
3
+ Version: 3.0.9
4
4
  Summary: MISP modules are autonomous modules that can be used for expansion and other services in MISP
5
5
  License-Expression: AGPL-3.0-only
6
6
  License-File: LICENSE
@@ -94,6 +94,8 @@ Requires-Dist: python-pptx ; extra == "all"
94
94
  Requires-Dist: pyzbar ; extra == "all"
95
95
  Requires-Dist: requests[security] ; extra == "all"
96
96
  Requires-Dist: requests[security] ; extra == "minimal"
97
+ Requires-Dist: rstapi (>=1.2.0,<2) ; extra == "all"
98
+ Requires-Dist: rstapi (>=1.2.0,<2) ; extra == "minimal"
97
99
  Requires-Dist: setuptools
98
100
  Requires-Dist: setuptools ; extra == "all"
99
101
  Requires-Dist: shodan ; extra == "all"
@@ -252,6 +254,14 @@ For further Information see the [license file](https://misp.github.io/misp-modul
252
254
  * [Real-time Blackhost Lists Lookup](https://misp.github.io/misp-modules/expansion/#real-time-blackhost-lists-lookup) - Module to check an IPv4 address against known RBLs.
253
255
  * [Recorded Future Enrich](https://misp.github.io/misp-modules/expansion/#recorded-future-enrich) - Module to enrich attributes with threat intelligence from Recorded Future.
254
256
  * [Reverse DNS](https://misp.github.io/misp-modules/expansion/#reverse-dns) - Simple Reverse DNS expansion service to resolve reverse DNS from MISP attributes.
257
+ * [RST Cloud Cobalt Strike Beacon](https://misp.github.io/misp-modules/expansion/#rst-cloud-cobalt-strike-beacon) - Scan a target for Cobalt Strike beacon configurations via RST Scan API.
258
+ * [RST Cloud Favicon](https://misp.github.io/misp-modules/expansion/#rst-cloud-favicon) - Fetch favicon image and hashes for Shodan/Netlas/Censys/FOFA pivoting via RST Scan API.
259
+ * [RST Cloud HTML Fetcher](https://misp.github.io/misp-modules/expansion/#rst-cloud-html-fetcher) - Fetch rendered HTML body or extracted JavaScript via RST Scan API.
260
+ * [RST Cloud IoC Lookup](https://misp.github.io/misp-modules/expansion/#rst-cloud-ioc-lookup) - Enrich indicators with RST Cloud threat intelligence.
261
+ * [RST Cloud Noise Control](https://misp.github.io/misp-modules/expansion/#rst-cloud-noise-control) - Check whether an indicator is known-good or noisy via RST Noise Control.
262
+ * [RST Cloud Screenshot](https://misp.github.io/misp-modules/expansion/#rst-cloud-screenshot) - Capture a page screenshot via RST Scan API.
263
+ * [RST Cloud SSL Certificate](https://misp.github.io/misp-modules/expansion/#rst-cloud-ssl-certificate) - Fetch TLS certificate as an x509 MISP object via RST Scan API.
264
+ * [RST Cloud Whois](https://misp.github.io/misp-modules/expansion/#rst-cloud-whois) - Retrieve parsed WHOIS for a domain via RST Cloud.
255
265
  * [ReversingLabs Spectra Analyze](https://misp.github.io/misp-modules/expansion/#reversinglabs-spectra-analyze) - Threat intelligence enrichment module
256
266
  * [SecurityTrails Lookup](https://misp.github.io/misp-modules/expansion/#securitytrails-lookup) - An expansion modules for SecurityTrails.
257
267
  * [Shodan Lookup](https://misp.github.io/misp-modules/expansion/#shodan-lookup) - Module to query on Shodan.
@@ -123,6 +123,14 @@ For further Information see the [license file](https://misp.github.io/misp-modul
123
123
  * [Real-time Blackhost Lists Lookup](https://misp.github.io/misp-modules/expansion/#real-time-blackhost-lists-lookup) - Module to check an IPv4 address against known RBLs.
124
124
  * [Recorded Future Enrich](https://misp.github.io/misp-modules/expansion/#recorded-future-enrich) - Module to enrich attributes with threat intelligence from Recorded Future.
125
125
  * [Reverse DNS](https://misp.github.io/misp-modules/expansion/#reverse-dns) - Simple Reverse DNS expansion service to resolve reverse DNS from MISP attributes.
126
+ * [RST Cloud Cobalt Strike Beacon](https://misp.github.io/misp-modules/expansion/#rst-cloud-cobalt-strike-beacon) - Scan a target for Cobalt Strike beacon configurations via RST Scan API.
127
+ * [RST Cloud Favicon](https://misp.github.io/misp-modules/expansion/#rst-cloud-favicon) - Fetch favicon image and hashes for Shodan/Netlas/Censys/FOFA pivoting via RST Scan API.
128
+ * [RST Cloud HTML Fetcher](https://misp.github.io/misp-modules/expansion/#rst-cloud-html-fetcher) - Fetch rendered HTML body or extracted JavaScript via RST Scan API.
129
+ * [RST Cloud IoC Lookup](https://misp.github.io/misp-modules/expansion/#rst-cloud-ioc-lookup) - Enrich indicators with RST Cloud threat intelligence.
130
+ * [RST Cloud Noise Control](https://misp.github.io/misp-modules/expansion/#rst-cloud-noise-control) - Check whether an indicator is known-good or noisy via RST Noise Control.
131
+ * [RST Cloud Screenshot](https://misp.github.io/misp-modules/expansion/#rst-cloud-screenshot) - Capture a page screenshot via RST Scan API.
132
+ * [RST Cloud SSL Certificate](https://misp.github.io/misp-modules/expansion/#rst-cloud-ssl-certificate) - Fetch TLS certificate as an x509 MISP object via RST Scan API.
133
+ * [RST Cloud Whois](https://misp.github.io/misp-modules/expansion/#rst-cloud-whois) - Retrieve parsed WHOIS for a domain via RST Cloud.
126
134
  * [ReversingLabs Spectra Analyze](https://misp.github.io/misp-modules/expansion/#reversinglabs-spectra-analyze) - Threat intelligence enrichment module
127
135
  * [SecurityTrails Lookup](https://misp.github.io/misp-modules/expansion/#securitytrails-lookup) - An expansion modules for SecurityTrails.
128
136
  * [Shodan Lookup](https://misp.github.io/misp-modules/expansion/#shodan-lookup) - Module to query on Shodan.
@@ -0,0 +1,19 @@
1
+ """Shared RST Cloud helpers for expansion modules (not registered)."""
2
+
3
+ from .client import ( # noqa: F401
4
+ apply_to_source_attribute,
5
+ error,
6
+ host_only,
7
+ misp_event_with_source,
8
+ new_enrichment_object,
9
+ rst_kwargs,
10
+ rst_resolver_from_config,
11
+ scan_group,
12
+ scan_kwargs,
13
+ scan_target,
14
+ standard_results,
15
+ text_result,
16
+ threat_tags,
17
+ unwrap,
18
+ value_from_request,
19
+ )
@@ -0,0 +1,528 @@
1
+ """Shared helpers for the RST Cloud expansion modules.
2
+
3
+ The modules ride the official ``rstapi`` library (PyPI) for transport, so a
4
+ misp-modules deployment just needs ``pip install rstapi``. These helpers cover
5
+ config parsing, error unwrapping, and the misp-modules result shape.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import json
11
+ import re
12
+
13
+ DEFAULT_BASE_URL = "https://api.rstcloud.net/v1"
14
+
15
+
16
+ def api_key_from_config(config: dict | None) -> str:
17
+ """misp-modules passes user config as a dict; accept common key names."""
18
+ config = config or {}
19
+ return (
20
+ config.get("api_key")
21
+ or config.get("apikey")
22
+ or config.get("rst_api_key")
23
+ or ""
24
+ )
25
+
26
+
27
+ def base_url_from_config(config: dict | None) -> str:
28
+ return (config or {}).get("base_url") or DEFAULT_BASE_URL
29
+
30
+
31
+ def rst_kwargs(config: dict | None) -> dict:
32
+ """Constructor kwargs shared by every rstapi client."""
33
+ return {
34
+ "APIKEY": api_key_from_config(config),
35
+ "APIURL": base_url_from_config(config),
36
+ }
37
+
38
+
39
+ def scan_kwargs(config: dict | None) -> dict:
40
+ """Constructor kwargs for rstapi.scan with optional read timeout.
41
+
42
+ Extends ``rst_kwargs``. Scan endpoints (ssl/html/favicon/screenshot/
43
+ cs-beacon) are synchronous: the RST Cloud server connects to the target
44
+ during your request, so they can take much longer than a database lookup.
45
+ The default rstapi READ timeout is 20 s, which is sometimes not enough.
46
+ Set ``timeout`` in the module config (seconds, default 60) to override it.
47
+ """
48
+ kw = rst_kwargs(config)
49
+ try:
50
+ kw["READ"] = max(1, int((config or {}).get("timeout") or 60))
51
+ except (ValueError, TypeError):
52
+ kw["READ"] = 60
53
+ return kw
54
+
55
+
56
+ def value_from_request(request: dict, keys) -> str | None:
57
+ """Pull the indicator from a misp-modules request (attribute or typed).
58
+
59
+ Handles all three shapes MISP sends: a full ``attribute`` object, a typed
60
+ top-level key (incl. composites like ``ip-dst|port``), and object-level
61
+ enrichment where the value lives in ``object["Attribute"]``.
62
+ """
63
+ if request.get("attribute"):
64
+ return request["attribute"].get("value")
65
+ for key in keys:
66
+ if request.get(key):
67
+ return request[key]
68
+ obj = request.get("object")
69
+ if isinstance(obj, dict):
70
+ wanted = set(keys)
71
+ for a in obj.get("Attribute") or []:
72
+ if a.get("type") in wanted and a.get("value"):
73
+ return a["value"]
74
+ return None
75
+
76
+
77
+ def host_only(value):
78
+ """Strip a MISP composite ``|port`` suffix; return bare host/indicator.
79
+
80
+ Used by the lookup modules (ioc / noise-control / whois) where the API keys
81
+ on the value itself and the port is irrelevant.
82
+ """
83
+ if not value:
84
+ return value
85
+ return str(value).split("|", 1)[0].strip()
86
+
87
+
88
+ _PORT_SUFFIX = re.compile(r":\d{1,5}$")
89
+ _PORT_RELATIONS = ("dst-port", "src-port", "port")
90
+
91
+
92
+ def _join_host_port(host: str, port) -> str:
93
+ """host:port, bracketing IPv6 literals so the colons aren't ambiguous."""
94
+ if host.count(":") >= 2 and not host.startswith("["):
95
+ return f"[{host}]:{port}"
96
+ return f"{host}:{port}"
97
+
98
+
99
+ def _has_explicit_port(host: str) -> bool:
100
+ # "1.2.3.4:443" / "host:443" — but not a bare IPv4 or IPv6 literal.
101
+ return bool(_PORT_SUFFIX.search(host)) and host.count(":") == 1
102
+
103
+
104
+ def _sibling_port(request) -> str | None:
105
+ """Port taken from a sibling attribute when MISP passes the whole object.
106
+
107
+ An ``ip-port`` object stores the port as its own attribute
108
+ (object_relation ``dst-port`` / ``src-port`` / ``port``); when MISP
109
+ includes ``object`` in the request, pick it up so the user doesn't have
110
+ to set one.
111
+ """
112
+ obj = request.get("object")
113
+ if not isinstance(obj, dict):
114
+ return None
115
+ for a in obj.get("Attribute") or []:
116
+ rel = (a.get("object_relation") or "").lower()
117
+ typ = (a.get("type") or "").lower()
118
+ if (rel in _PORT_RELATIONS or typ == "port") and a.get("value"):
119
+ return str(a["value"]).strip()
120
+ return None
121
+
122
+
123
+ def scan_target(
124
+ request,
125
+ inputs,
126
+ config,
127
+ *,
128
+ as_url=False,
129
+ default_port=None,
130
+ default_scheme="https",
131
+ ):
132
+ """Build a Scan-API target from a MISP attribute with optional port.
133
+
134
+ IP/host attributes carry no port, but the Scan API addresses a *service*:
135
+ ``host:port`` for ssl / cs-beacon / favicon, or a URL for html /
136
+ screenshot. Port resolution, most specific first:
137
+
138
+ 1. an explicit port already in the value (``1.2.3.4:8443`` or a URL),
139
+ 2. a MISP ``host|port`` composite (e.g. an ``ip-dst|port`` attribute),
140
+ 3. a sibling port attribute in the same MISP object (``ip-port``),
141
+ 4. the optional ``port`` set in the module config,
142
+ 5. ``default_port`` (module-specific fallback, may be ``None``).
143
+
144
+ For URL endpoints (``as_url=True``) a bare host becomes
145
+ ``<scheme>://host[:port]`` where scheme is the config ``scheme`` or
146
+ ``default_scheme``. Returns ``None`` when no value is present.
147
+ """
148
+ raw = value_from_request(request, inputs)
149
+ if not raw:
150
+ return None
151
+ raw = str(raw).strip()
152
+ cfg = config or {}
153
+
154
+ if raw.startswith(("http://", "https://")):
155
+ return raw # already a full URL — it encodes its own port
156
+
157
+ # Port, most specific source first.
158
+ port = None
159
+ if "|" in raw: # MISP composite "host|port"
160
+ host, _, p = raw.partition("|")
161
+ raw, port = host.strip(), (p.strip() or None)
162
+ port = port or _sibling_port(request) or (cfg.get("port") or None)
163
+
164
+ has_port = _has_explicit_port(raw) # value was already "host:port"
165
+ if as_url:
166
+ scheme = (cfg.get("scheme") or default_scheme).strip().lower()
167
+ host = raw if has_port or not port else _join_host_port(raw, port)
168
+ return f"{scheme}://{host}"
169
+
170
+ # host:port endpoints (ssl / cs-beacon / favicon)
171
+ if has_port:
172
+ return raw
173
+ p = port or default_port
174
+ return _join_host_port(raw, p) if p else raw
175
+
176
+
177
+ def unwrap(resp):
178
+ """Return (data, None) or (None, error_message) for an rstapi response."""
179
+ if isinstance(resp, dict) and resp.get("status") == "error":
180
+ return None, str(resp.get("message", "RST Cloud API error"))
181
+ return resp, None
182
+
183
+
184
+ def error(message: str) -> dict:
185
+ return {"error": message}
186
+
187
+
188
+ # Threat-suffix -> (built-in MISP galaxy predicate, RST galaxy stix_type).
189
+ # Kept in sync with rstmisp.misp.tagging; duplicated here so the modules
190
+ # stay droppable into misp-modules standalone. The 2nd element selects which
191
+ # RST custom galaxy (rst-<stix_type>) a name belongs to when resolving the
192
+ # real cluster tag.
193
+ _THREAT_SUFFIX = {
194
+ "_group": ("misp-galaxy:threat-actor", "intrusion-set"),
195
+ "_actor": ("misp-galaxy:threat-actor", "intrusion-set"),
196
+ "_tool": ("misp-galaxy:tool", "tool"),
197
+ "_stealer": ("misp-galaxy:stealer", "malware"),
198
+ "_backdoor": ("misp-galaxy:backdoor", "malware"),
199
+ "_ransomware": ("misp-galaxy:ransomware", "malware"),
200
+ "_miner": ("misp-galaxy:cryptominers", "malware"),
201
+ "_exploit": ("misp-galaxy:exploit-kit", "malware"),
202
+ "_botnet": ("misp-galaxy:botnet", "malware"),
203
+ "_rat": ("misp-galaxy:rat", "malware"),
204
+ "_campaign": ("misp-galaxy:campaign", "campaign"),
205
+ }
206
+ # Names with no recognised suffix are malware families.
207
+ _THREAT_DEFAULT = ("misp-galaxy:malware", "malware")
208
+
209
+ # RST custom galaxy types in MISP (namespace rstcloud); stix_type = type[4:].
210
+ _RST_GALAXY_TYPES = (
211
+ "rst-malware",
212
+ "rst-tool",
213
+ "rst-intrusion-set",
214
+ "rst-campaign",
215
+ )
216
+
217
+ # Per-process caches: a misp-modules worker is long-lived, so reuse the PyMISP
218
+ # client + resolved galaxy ids across calls instead of reconnecting on every
219
+ # hover.
220
+ _RESOLVER_CACHE: dict = {}
221
+
222
+
223
+ def _truthy(v) -> bool:
224
+ if isinstance(v, bool):
225
+ return v
226
+ return str(v).strip().lower() in ("1", "true", "yes", "on")
227
+
228
+
229
+ class _RstClusterResolver:
230
+ """Resolve an RST threat ``(stix_type, name)`` to its MISP cluster's real
231
+ ``tag_name`` (``misp-galaxy:rst-*="<cluster-uuid>"``), so an enrichment tag
232
+ attaches the RST Threat Library galaxy — the same node the library/
233
+ reports/ feed connectors use. MISP stores a CUSTOM cluster's tag keyed on
234
+ the UUID, not the name, so the value-form ``rstcloud:rst-*="name"``
235
+ would not link.
236
+
237
+ Targeted ``search_galaxy_clusters`` per name (a handful per enrichment
238
+ call), not a full galaxy pull; per-name results are memoised on the
239
+ instance.
240
+ """
241
+
242
+ def __init__(self, misp, galaxy_ids: dict):
243
+ self._misp = misp
244
+ self._ids = galaxy_ids
245
+ self._cache: dict = {}
246
+
247
+ def __call__(self, stix_type: str, name_lower: str):
248
+ gid = self._ids.get("rst-" + stix_type)
249
+ if not gid:
250
+ return None
251
+ key = (stix_type, name_lower)
252
+ if key not in self._cache:
253
+ self._cache[key] = self._lookup(gid, name_lower)
254
+ return self._cache[key]
255
+
256
+ def _lookup(self, gid, name_lower):
257
+ try:
258
+ clusters = self._misp.search_galaxy_clusters(
259
+ gid, context="all", searchall=name_lower, pythonify=False
260
+ )
261
+ except Exception:
262
+ return None
263
+ for c in clusters or []:
264
+ gc = c.get("GalaxyCluster", c)
265
+ tname = gc.get("tag_name")
266
+ if not tname:
267
+ continue
268
+ if (gc.get("value") or "").lower() == name_lower:
269
+ return tname
270
+ for el in gc.get("GalaxyElement") or []:
271
+ if (
272
+ el.get("key") == "synonyms"
273
+ and (el.get("value") or "").lower() == name_lower
274
+ ):
275
+ return tname
276
+ return None
277
+
278
+
279
+ def rst_resolver_from_config(config: dict | None):
280
+ """Build an RST cluster resolver from optional MISP config, or None.
281
+
282
+ Needs ``misp_url`` + ``misp_key`` in the module config; without them
283
+ (the default standalone deployment) returns None and ``threat_tags`` falls
284
+ back to built-in galaxy tags. PyMISP is imported lazily so the modules
285
+ still install with just ``rstapi`` when MISP resolution isn't configured.
286
+ """
287
+ config = config or {}
288
+ url = config.get("misp_url")
289
+ key = config.get("misp_key")
290
+ if not url or not key:
291
+ return None
292
+ if url in _RESOLVER_CACHE:
293
+ return _RESOLVER_CACHE[url]
294
+ try:
295
+ from pymisp import PyMISP
296
+ except Exception:
297
+ return None
298
+ try:
299
+ misp = PyMISP(
300
+ url, key, ssl=_truthy(config.get("misp_verifycert", False))
301
+ )
302
+ ids = {}
303
+ for g in misp.galaxies(pythonify=False) or []:
304
+ gd = g.get("Galaxy", g)
305
+ if gd.get("type") in _RST_GALAXY_TYPES and gd.get("id"):
306
+ ids.setdefault(gd["type"], gd["id"])
307
+ except Exception:
308
+ return None
309
+ resolver = _RstClusterResolver(misp, ids)
310
+ _RESOLVER_CACHE[url] = resolver
311
+ return resolver
312
+
313
+
314
+ def threat_tags(threats, rst_resolver=None) -> list:
315
+ """Map RST threat names to MISP galaxy tags (best-effort, suffix-driven).
316
+
317
+ When ``rst_resolver`` is supplied (built from MISP config), each name first
318
+ resolves to its RST Threat Library cluster's real ``tag_name`` so the tag
319
+ attaches that galaxy; on a miss (or when no resolver) it falls back to the
320
+ built-in ``misp-galaxy:*`` value-form tag. ``rst_resolver`` is any callable
321
+ ``(stix_type, name_lower) -> tag_name | None``.
322
+ """
323
+ tags = []
324
+ for threat in threats or []:
325
+ if threat.endswith(("_technique", "_vuln")):
326
+ continue
327
+ predicate, stix_type = _THREAT_DEFAULT
328
+ name = threat
329
+ for suffix, (pred, st) in _THREAT_SUFFIX.items():
330
+ if threat.endswith(suffix):
331
+ n = len(suffix)
332
+ predicate, stix_type, name = pred, st, threat[:-n]
333
+ break
334
+ clean = name.replace("_", " ")
335
+ tag = None
336
+ if rst_resolver:
337
+ try:
338
+ tag = rst_resolver(stix_type, clean.lower())
339
+ except Exception:
340
+ tag = None
341
+ tags.append(tag or f'{predicate}="{clean}"')
342
+ return tags
343
+
344
+
345
+ def scan_group(request, source):
346
+ """uuid scan-result objects should reference so each result stays tied
347
+ to exactly what was enriched — without spawning extra container objects.
348
+
349
+ 1. the parent object, when MISP includes it in the request (``object``);
350
+ 2. otherwise the enriched source attribute itself.
351
+
352
+ A screenshot / certificate / fetched body cannot be an *attribute* of a
353
+ ``url`` / ``ip-port`` / ``domain-ip`` object — MISP object templates are
354
+ fixed and have no such relation — so each is returned as its own object
355
+ that references this anchor (``identifies`` / ``screenshot-of`` / …).
356
+ Returns the anchor uuid, or ``None`` (typed-key request with no attribute
357
+ to point at).
358
+ """
359
+ obj = request.get("object")
360
+ if isinstance(obj, dict) and obj.get("uuid"):
361
+ return obj["uuid"]
362
+ return source.uuid if source is not None else None
363
+
364
+
365
+ def misp_event_with_source(request):
366
+ """Start a ``MISPEvent`` seeded with the triggering attribute.
367
+
368
+ Returns ``(event, source_attribute_or_None)``. Enrichment objects/
369
+ attributes added to the event can ``add_reference(source.uuid, ...)`` so
370
+ MISP links them to the attribute the analyst enriched. Requires pymisp,
371
+ present in a misp-modules deployment (it's a core dependency).
372
+ """
373
+ from pymisp import MISPAttribute, MISPEvent
374
+
375
+ event = MISPEvent()
376
+ source = None
377
+ attr = request.get("attribute")
378
+ if attr:
379
+ source = MISPAttribute()
380
+ source.from_dict(**attr)
381
+ event.add_attribute(**source)
382
+ return event, source
383
+
384
+
385
+ def new_enrichment_object(name):
386
+ """Build a ``MISPObject`` for an RST enrichment template.
387
+
388
+ Returns ``(object, dedicated)``. Uses the ``rst-*`` template from the MISP
389
+ object library (install via
390
+ [MISP/misp-objects](https://github.com/MISP/misp-objects), e.g.
391
+ [PR #526](https://github.com/MISP/misp-objects/pull/526)). Falls back to
392
+ a generic ``annotation`` object if the template is not installed yet, so
393
+ output stays valid misp_standard on any MISP.
394
+ """
395
+ from pymisp import MISPObject
396
+
397
+ try:
398
+ obj = MISPObject(name)
399
+ if getattr(obj, "_known_template", False):
400
+ return obj, True
401
+ except Exception:
402
+ pass
403
+ return MISPObject("annotation"), False
404
+
405
+
406
+ def standard_results(event) -> dict:
407
+ """Serialise a ``MISPEvent`` into the misp_standard result envelope."""
408
+ parsed = json.loads(event.to_json())
409
+ return {
410
+ "results": {
411
+ k: parsed[k] for k in ("Attribute", "Object") if parsed.get(k)
412
+ }
413
+ }
414
+
415
+
416
+ def text_result(value: str, comment: str = "") -> dict:
417
+ """misp_standard fallback when nothing structured to return (one text)."""
418
+ attr = {"type": "text", "value": value}
419
+ if comment:
420
+ attr["comment"] = comment
421
+ return {"results": {"Attribute": [attr]}}
422
+
423
+
424
+ _PYMISP_CACHE: dict = {}
425
+
426
+
427
+ def _pymisp(cfg):
428
+ """Cached PyMISP client from module config (misp_url/misp_key), or None.
429
+
430
+ Reused across calls (a misp-modules worker is long-lived). Returns None
431
+ when creds are absent or PyMISP can't connect, so callers degrade
432
+ gracefully.
433
+ """
434
+ url, key = cfg.get("misp_url"), cfg.get("misp_key")
435
+ if not (url and key):
436
+ return None
437
+ ck = (url, key, bool(_truthy(cfg.get("misp_verifycert", False))))
438
+ if ck in _PYMISP_CACHE:
439
+ return _PYMISP_CACHE[ck]
440
+ try:
441
+ from pymisp import PyMISP
442
+
443
+ client = PyMISP(url, key, ssl=ck[2])
444
+ except Exception:
445
+ return None
446
+ _PYMISP_CACHE[ck] = client
447
+ return client
448
+
449
+
450
+ def apply_to_source_attribute(
451
+ config,
452
+ request,
453
+ *,
454
+ tags=None,
455
+ comment_note=None,
456
+ comment_prefix=None,
457
+ replace_tag_prefixes=(),
458
+ set_to_ids=None,
459
+ fp_sightings=0,
460
+ ):
461
+ """Write enrichment back ONTO the enriched attribute via the MISP API.
462
+
463
+ MISP enrichment itself can only ADD new attributes/objects — it can't
464
+ modify the attribute you ran the module on. So, *only when*
465
+ ``misp_url``/``misp_key`` are set in the module config, this updates the
466
+ source attribute in place:
467
+
468
+ * removes the module's own prior tags (``replace_tag_prefixes``) then
469
+ adds ``tags`` — so re-running replaces rather than stacks verdicts;
470
+ * appends ``comment_note`` to the existing comment (dropping any
471
+ previous note that started with ``comment_prefix``, so re-runs stay
472
+ tidy);
473
+ * sets ``to_ids`` when ``set_to_ids`` is not None;
474
+ * adds ``fp_sightings`` false-positive sightings (type 1) — a benign
475
+ signal that feeds MISP's decay/scoring.
476
+
477
+ Returns True if it wrote back (caller should then return an empty result
478
+ so no duplicate attribute is created); False otherwise (caller returns
479
+ normally).
480
+ """
481
+ cfg = config or {}
482
+ attr = request.get("attribute") or {}
483
+ uuid = attr.get("uuid")
484
+ misp = _pymisp(cfg)
485
+ if not (uuid and misp):
486
+ return False
487
+ try:
488
+ full = misp.get_attribute(uuid, pythonify=True)
489
+ except Exception:
490
+ return False
491
+ try:
492
+ changed = False
493
+ if comment_note is not None:
494
+ existing = (
495
+ getattr(full, "comment", None) or attr.get("comment") or ""
496
+ )
497
+ segments = [
498
+ s
499
+ for s in existing.split(" | ")
500
+ if s and not (comment_prefix and s.startswith(comment_prefix))
501
+ ]
502
+ segments.append(comment_note)
503
+ full.comment = " | ".join(segments)
504
+ changed = True
505
+ if set_to_ids is not None:
506
+ full.to_ids = bool(set_to_ids)
507
+ changed = True
508
+ if changed:
509
+ misp.update_attribute(full)
510
+ if replace_tag_prefixes:
511
+ for t in getattr(full, "tags", []) or []:
512
+ name = getattr(t, "name", "") or ""
513
+ if any(name.startswith(p) for p in replace_tag_prefixes):
514
+ misp.untag(uuid, name)
515
+ for tag in tags or []:
516
+ misp.tag(uuid, tag)
517
+ if fp_sightings:
518
+ from pymisp import MISPSighting
519
+
520
+ for _ in range(int(fp_sightings)):
521
+ sighting = MISPSighting()
522
+ sighting.from_dict(
523
+ type="1", source="RST Noise Control"
524
+ ) # 1 = false-positive
525
+ misp.add_sighting(sighting, attribute=uuid)
526
+ return True
527
+ except Exception:
528
+ return False