├── .bumpversion.cfg ├── .circleci └── config.yml ├── .coveragerc ├── .dockerignore ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md └── workflows │ └── git_sync.yaml ├── .gitignore ├── .pyup.yml ├── .readthedocs.yaml ├── CHANGELOG.rst ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.rst ├── changes ├── .gitkeep ├── 9f92991a0588f9631ecd85cc63c61ad0.yaml ├── ba56868fd6953c1b4488517a55393fc3.yaml └── modelrefs │ ├── model_2.176.0_16ee721a6b7221344eaf946c3ab4602dda546b1a.yaml.gz │ ├── model_2.177.0_b7da795aeb690020e38e99dc5aa1f505cdc2d659.yaml.gz │ ├── model_2.179.0_1c51c58523e9012655d8d18bfa1ad149e5536c25.yaml.gz │ ├── model_2.180.0_aecbb8c0839f3ad763076dd7acae968fae6ba8b7.yaml.gz │ ├── model_2.181.0_9241eebaad4a9c7bb007c6c5abb63be4e4ffac44.yaml.gz │ ├── model_2.183.0_68e4f3dd36f4ff9dd7818ea2c8180b086092148f.yaml.gz │ ├── model_2.184.0_05940dce070d26f83bb7e4070f1d44d051804e3b.yaml.gz │ ├── model_2.185.0_c2ef0eded02f8ac5f34704a117947f44095f41f4.yaml.gz │ ├── model_2.186.0_ffa4abc52513d4b8ac592496322227eed9e07dc5.yaml.gz │ ├── model_2.188.0_6d1f734406234e3750c72f5bf299f89a13d0825a.yaml.gz │ ├── model_2.189.0_0cec341c3b35e19b0cb34c1d5210afb0790cba99.yaml.gz │ ├── model_2.191.0_f6b07ada7cb68701e769e155735c9c004a404454.yaml.gz │ ├── model_2.193.0_ad17bf2e740ba11453b7827ce70c140f969a1430.yaml.gz │ ├── model_2.194.0_fb479d376805f963f11c5029310325c13ef2c883.yaml.gz │ ├── model_2.195.0_dc93864afdb2150e6d83ac4ed426c8e99bb3a448.yaml.gz │ ├── model_2.196.0_8182360d2ebf8e8bdd00cb72f03812061c819cc2.yaml.gz │ ├── model_2.197.0_c8c758131cae47ef21e23ac8242012459ebfce9d.yaml.gz │ ├── model_2.198.0_047e5e996d0bcaad4ada4ea390a726aca1abba9b.yaml.gz │ ├── model_2.201.0_eed8c13ff316a77ae835539215c862d052d31994.yaml.gz │ ├── model_2.203.0_809ecdca2e2b05f1cd111bb23c237127b2b9c177.yaml.gz │ ├── model_2.204.0_6b616fcd2d70a036d9853355fcb6fd491e84f015.yaml.gz │ ├── model_2.205.0_d985f8b93669529b2d90895baabb1dc289e287df.yaml.gz │ ├── model_2.206.0_0be7ce9e061b2c752fb454adb50c5267cc14fdfe.yaml.gz │ ├── model_2.210.0_e43efa9d9c2257ff05fe47988a323e16896fdf50.yaml.gz │ ├── model_2.211.0_99beab651131ab996a967c6d0345c80b89de4a74.yaml.gz │ └── model_2.212.0_68ec8184b0e2469fd1ef30cbeb29f5989c60c768.yaml.gz ├── codecov.yml ├── conftest.py ├── docker ├── README.rst ├── bootstrap.sh ├── build_all.sh ├── build_image.sh ├── images │ ├── aha │ │ ├── Dockerfile │ │ └── entrypoint.sh │ ├── axon │ │ ├── Dockerfile │ │ └── entrypoint.sh │ ├── cortex │ │ ├── Dockerfile │ │ └── entrypoint.sh │ ├── cryotank │ │ ├── Dockerfile │ │ └── entrypoint.sh │ ├── jsonstor │ │ ├── Dockerfile │ │ └── entrypoint.sh │ ├── stemcell │ │ ├── Dockerfile │ │ └── entrypoint.sh │ └── synapse │ │ └── Dockerfile ├── rmlist.txt └── scripts │ ├── copy_all.sh │ ├── push_all.sh │ ├── retag_all.sh │ └── test_all.sh ├── docs ├── 404.rst ├── Makefile ├── _static │ ├── css │ │ └── theme_overrides.css │ ├── favicon.svg │ └── logo.svg ├── _templates │ └── breadcrumbs.html ├── conf.py ├── docdata │ ├── README.txt │ ├── foopkg │ │ ├── foopkg.yml │ │ └── storm │ │ │ ├── commands │ │ │ └── foocmd │ │ │ ├── modules │ │ │ └── foomod │ │ │ └── optic │ │ │ └── index.html │ └── mastering_example_ingest.json ├── index.rst └── synapse │ ├── adminguide.rstorm │ ├── apidocs.rst │ ├── changelog.rst │ ├── contributing.rst │ ├── contributing │ ├── contributing.rst │ ├── doc_mastering.rst │ └── release_process.rst │ ├── datamodel.rst │ ├── datamodel_deprecation.rst │ ├── deploymentguide.rst │ ├── devguide.rst │ ├── devguides │ ├── adduserimage.sh │ ├── adv_power_ups.rst │ ├── architecture.rst │ ├── certbot.sh │ ├── docker.rst │ ├── power-ups.rst │ └── storm_api.rst │ ├── devopsguide.rst │ ├── glossary.rst │ ├── httpapi.rst │ ├── intro.rst │ ├── kubernetes │ ├── aha.yaml │ ├── axon.yaml │ ├── cortex.yaml │ ├── jsonstor.yaml │ ├── optic.yaml │ └── sysctl.yaml │ ├── power_ups.rst │ ├── quickstart.rst │ ├── stormtypes.rst │ ├── support.rst │ ├── user_interface.rst │ ├── userguide.rst │ └── userguides │ ├── analytical_model.rstorm │ ├── background.rst │ ├── data_model.rstorm │ ├── index_model_updates.rst │ ├── index_storm_adv.rst │ ├── index_storm_ref.rst │ ├── index_tools.rst │ ├── model_updates │ ├── update_v2_133_0.rst │ ├── update_v2_134_0.rst │ ├── update_v2_137_0.rst │ ├── update_v2_140_0.rst │ ├── update_v2_141_0.rst │ ├── update_v2_142_0.rst │ ├── update_v2_143_0.rst │ ├── update_v2_144_0.rst │ ├── update_v2_145_0.rst │ ├── update_v2_149_0.rst │ ├── update_v2_150_0.rst │ ├── update_v2_151_0.rst │ ├── update_v2_152_0.rst │ ├── update_v2_153_0.rst │ ├── update_v2_154_0.rst │ ├── update_v2_155_0.rst │ ├── update_v2_156_0.rst │ ├── update_v2_160_0.rst │ ├── update_v2_162_0.rst │ ├── update_v2_165_0.rst │ ├── update_v2_166_0.rst │ ├── update_v2_167_0.rst │ ├── update_v2_168_0.rst │ ├── update_v2_170_0.rst │ ├── update_v2_172_0.rst │ ├── update_v2_173_0.rst │ ├── update_v2_173_1.rst │ ├── update_v2_174_0.rst │ ├── update_v2_176_0.rst │ ├── update_v2_177_0.rst │ ├── update_v2_179_0.rst │ ├── update_v2_180_0.rst │ ├── update_v2_181_0.rst │ ├── update_v2_183_0.rst │ ├── update_v2_184_0.rst │ ├── update_v2_185_0.rst │ ├── update_v2_186_0.rst │ ├── update_v2_187_0.rst │ ├── update_v2_188_0.rst │ ├── update_v2_189_0.rst │ ├── update_v2_191_0.rst │ ├── update_v2_193_0.rst │ ├── update_v2_194_0.rst │ ├── update_v2_195_0.rst │ ├── update_v2_196_0.rst │ ├── update_v2_197_0.rst │ ├── update_v2_198_0.rst │ ├── update_v2_201_0.rst │ ├── update_v2_203_0.rst │ ├── update_v2_204_0.rst │ ├── update_v2_205_0.rst │ ├── update_v2_206_0.rst │ ├── update_v2_210_0.rst │ ├── update_v2_211_0.rst │ └── update_v2_212_0.rst │ ├── storm_adv_control.rstorm │ ├── storm_adv_functions.rstorm │ ├── storm_adv_methods.rstorm │ ├── storm_adv_vars.rstorm │ ├── storm_ref_automation.rstorm │ ├── storm_ref_cmd.rstorm │ ├── storm_ref_data_mod.rstorm │ ├── storm_ref_filter.rstorm │ ├── storm_ref_intro.rst │ ├── storm_ref_lift.rstorm │ ├── storm_ref_model_introspect.rstorm │ ├── storm_ref_pivot.rstorm │ ├── storm_ref_subquery.rstorm │ ├── storm_ref_syntax.rst │ ├── storm_ref_type_specific.rstorm │ ├── syn_tools_csvtool.rst │ ├── syn_tools_easycert.rst │ ├── syn_tools_feed.rst │ ├── syn_tools_genpkg.rst │ ├── syn_tools_pullfile.rst │ ├── syn_tools_pushfile.rst │ ├── syn_tools_storm.rstorm │ └── views_layers.rst ├── examples ├── httpapi │ ├── aiohttp_storm_example.py │ └── requests_storm_example.py └── power-ups │ └── rapid │ └── acme-hello │ ├── acme-hello.yaml │ ├── storm │ ├── commands │ │ ├── acme.hello.mayyield.storm │ │ ├── acme.hello.omgopts.storm │ │ └── acme.hello.sayhi.storm │ └── modules │ │ ├── acme.hello.privsep.storm │ │ └── acme.hello.storm │ └── test_acme_hello.py ├── process_stats.py ├── pyproject.toml ├── requirements.txt ├── requirements_dev.txt ├── requirements_doc.txt ├── scripts ├── __init__.py ├── benchmark_cortex.py ├── doctests.py ├── githooks │ └── pre-commit ├── pep8_staged_files.py ├── replace_commit.py ├── testrunner.sh └── verify_version.py ├── setup.cfg └── synapse ├── __init__.py ├── axon.py ├── cells.py ├── cmds ├── __init__.py ├── boss.py ├── cortex.py └── hive.py ├── common.py ├── cortex.py ├── cryotank.py ├── daemon.py ├── data ├── __init__.py ├── attack-flow │ ├── LICENSE.txt │ ├── README.md │ └── attack-flow-schema-2.0.0.json ├── certs │ ├── cas │ │ ├── The Vertex Project Intermediate CA 00.crt │ │ └── The Vertex Project ROOT CA.crt │ └── crls │ │ ├── The Vertex Project Intermediate CA 00.crl │ │ └── The Vertex Project ROOT CA.crl ├── iana.tlds.mpk ├── iana.uris.mpk └── jsonschemas │ ├── README.md │ └── raw.githubusercontent.com │ └── oasis-open │ ├── LICENSE.txt │ └── cti-stix2-json-schemas │ └── stix2.1 │ └── schemas │ ├── common │ ├── binary.json │ ├── bundle.json │ ├── core.json │ ├── cyber-observable-core.json │ ├── dictionary.json │ ├── extension-definition.json │ ├── extension.json │ ├── external-reference.json │ ├── granular-marking.json │ ├── hashes-type.json │ ├── hex.json │ ├── identifier.json │ ├── kill-chain-phase.json │ ├── language-content.json │ ├── marking-definition.json │ ├── properties.json │ ├── timestamp.json │ └── url-regex.json │ ├── observables │ ├── artifact.json │ ├── autonomous-system.json │ ├── directory.json │ ├── domain-name.json │ ├── email-addr.json │ ├── email-message.json │ ├── file.json │ ├── ipv4-addr.json │ ├── ipv6-addr.json │ ├── mac-addr.json │ ├── mutex.json │ ├── network-traffic.json │ ├── process.json │ ├── software.json │ ├── url.json │ ├── user-account.json │ ├── windows-registry-key.json │ └── x509-certificate.json │ ├── sdos │ ├── attack-pattern.json │ ├── campaign.json │ ├── course-of-action.json │ ├── grouping.json │ ├── identity.json │ ├── incident.json │ ├── indicator.json │ ├── infrastructure.json │ ├── intrusion-set.json │ ├── location.json │ ├── malware-analysis.json │ ├── malware.json │ ├── note.json │ ├── observed-data.json │ ├── opinion.json │ ├── report.json │ ├── threat-actor.json │ ├── tool.json │ └── vulnerability.json │ └── sros │ ├── relationship.json │ └── sighting.json ├── datamodel.py ├── exc.py ├── glob.py ├── lib ├── __init__.py ├── agenda.py ├── aha.py ├── ast.py ├── auth.py ├── autodoc.py ├── base.py ├── boss.py ├── cache.py ├── cell.py ├── certdir.py ├── chop.py ├── cli.py ├── cmd.py ├── cmdr.py ├── config.py ├── const.py ├── coro.py ├── crypto │ ├── __init__.py │ ├── coin.py │ ├── ecc.py │ ├── passwd.py │ ├── rsa.py │ └── tinfoil.py ├── datfile.py ├── drive.py ├── dyndeps.py ├── encoding.py ├── gis.py ├── grammar.py ├── hashitem.py ├── hashset.py ├── health.py ├── hive.py ├── httpapi.py ├── ingest.py ├── interval.py ├── json.py ├── jsonstor.py ├── layer.py ├── link.py ├── lmdbslab.py ├── modelrev.py ├── module.py ├── modules.py ├── msgpack.py ├── multislabseqn.py ├── nexus.py ├── node.py ├── oauth.py ├── output.py ├── parser.py ├── platforms │ ├── __init__.py │ ├── common.py │ ├── darwin.py │ ├── freebsd.py │ ├── linux.py │ └── windows.py ├── queue.py ├── ratelimit.py ├── reflect.py ├── rstorm.py ├── schemas.py ├── scope.py ├── scrape.py ├── share.py ├── slaboffs.py ├── slabseqn.py ├── snap.py ├── spooled.py ├── storm.lark ├── storm.py ├── storm_format.py ├── stormctrl.py ├── stormhttp.py ├── stormlib │ ├── __init__.py │ ├── aha.py │ ├── auth.py │ ├── backup.py │ ├── basex.py │ ├── cache.py │ ├── cell.py │ ├── compression.py │ ├── cortex.py │ ├── easyperm.py │ ├── env.py │ ├── ethereum.py │ ├── gen.py │ ├── gis.py │ ├── graph.py │ ├── hashes.py │ ├── hex.py │ ├── imap.py │ ├── index.py │ ├── infosec.py │ ├── ipv6.py │ ├── iters.py │ ├── json.py │ ├── log.py │ ├── macro.py │ ├── math.py │ ├── mime.py │ ├── model.py │ ├── modelext.py │ ├── notifications.py │ ├── oauth.py │ ├── pack.py │ ├── project.py │ ├── random.py │ ├── scrape.py │ ├── smtp.py │ ├── spooled.py │ ├── stats.py │ ├── stix.py │ ├── storm.py │ ├── tabular.py │ ├── utils.py │ ├── vault.py │ ├── version.py │ ├── xml.py │ └── yaml.py ├── stormsvc.py ├── stormtypes.py ├── stormwhois.py ├── structlog.py ├── task.py ├── thishost.py ├── thisplat.py ├── threads.py ├── time.py ├── trigger.py ├── types.py ├── urlhelp.py ├── version.py └── view.py ├── lookup ├── __init__.py ├── cvss.py ├── iana.py ├── iso3166.py ├── macho.py ├── pe.py ├── phonenum.py └── timezones.py ├── mindmeld.py ├── models ├── __init__.py ├── auth.py ├── base.py ├── belief.py ├── biz.py ├── crypto.py ├── dns.py ├── doc.py ├── economic.py ├── entity.py ├── files.py ├── geopol.py ├── geospace.py ├── gov │ ├── __init__.py │ ├── cn.py │ ├── intl.py │ └── us.py ├── inet.py ├── infotech.py ├── language.py ├── material.py ├── math.py ├── media.py ├── orgs.py ├── person.py ├── planning.py ├── proj.py ├── risk.py ├── science.py ├── syn.py ├── telco.py └── transport.py ├── servers ├── __init__.py ├── aha.py ├── axon.py ├── cell.py ├── cortex.py ├── cryotank.py ├── jsonstor.py └── stemcell.py ├── telepath.py ├── tests ├── __init__.py ├── files │ ├── TestUtilsGetrefs.test_basics.yaml │ ├── __init__.py │ ├── aha │ │ └── certs │ │ │ ├── cas │ │ │ ├── synapse.crt │ │ │ └── synapse.key │ │ │ ├── hosts │ │ │ ├── 00.aha.loop.vertex.link.crt │ │ │ └── 00.aha.loop.vertex.link.key │ │ │ └── users │ │ │ ├── root@synapse.crt │ │ │ └── root@synapse.key │ ├── attack_flow │ │ ├── CISA AA22-138B VMWare Workspace (Alt).json │ │ └── CISA_Iranian_APT.json │ ├── certdir │ │ ├── cas │ │ │ ├── ca.crt │ │ │ └── ca.key │ │ ├── hosts │ │ │ ├── localhost.crt │ │ │ └── localhost.key │ │ └── users │ │ │ ├── root.crt │ │ │ ├── root.key │ │ │ ├── user.crt │ │ │ └── user.key │ ├── changelog │ │ ├── model_2.176.0_16ee721a6b7221344eaf946c3ab4602dda546b1a.yaml.gz │ │ └── model_2.176.0_2a25c58bbd344716cd7cbc3f4304d8925b0f4ef2.yaml.gz │ ├── cpedata.json │ ├── rstorm │ │ ├── httpresp1.json │ │ ├── httpresp2.json │ │ ├── httpresp3.json │ │ ├── httprespmulti.yaml │ │ └── testsvc.py │ ├── stix_export │ │ ├── basic.json │ │ ├── custom0.json │ │ └── risk0.json │ ├── stix_import │ │ ├── apt1.json │ │ └── oasis-example-00.json │ ├── stormcov │ │ ├── argvquery.storm │ │ ├── dupesubs.storm │ │ ├── lookup.storm │ │ ├── pivot.storm │ │ ├── pragma-nocov.storm │ │ ├── spin.storm │ │ └── stormctrl.storm │ ├── stormmod │ │ └── common │ ├── stormpkg │ │ ├── badapidef.yaml │ │ ├── badcmdname.yaml │ │ ├── badendpoints.yaml │ │ ├── badjsonpkg.yaml │ │ ├── docs │ │ │ ├── foobar.md │ │ │ └── foobar.svg │ │ ├── dotstorm │ │ │ ├── dotstorm.yaml │ │ │ └── storm │ │ │ │ ├── commands │ │ │ │ └── dotstorm.bar.storm │ │ │ │ └── modules │ │ │ │ └── dotstorm.foo.storm │ │ ├── nocontent.yaml │ │ ├── nomime.yaml │ │ ├── nopath.yaml │ │ ├── nosuchfile.yaml │ │ ├── notitle.yaml │ │ ├── optic │ │ │ └── index.html │ │ ├── storm │ │ │ ├── commands │ │ │ │ ├── invalidCMD │ │ │ │ ├── testpkg.baz │ │ │ │ └── testpkgcmd │ │ │ └── modules │ │ │ │ ├── apimod │ │ │ │ └── testmod │ │ ├── testpkg.yaml │ │ └── workflows │ │ │ ├── testpkg-bam.newp │ │ │ ├── testpkg-baz.yaml │ │ │ └── testpkg-foo.yaml │ ├── test.dat │ └── testcore │ │ └── cell.yaml ├── nopmod.py ├── test_axon.py ├── test_cmds_boss.py ├── test_cmds_cortex.py ├── test_cmds_hive.py ├── test_common.py ├── test_cortex.py ├── test_cryotank.py ├── test_daemon.py ├── test_data.py ├── test_datamodel.py ├── test_exc.py ├── test_glob.py ├── test_init.py ├── test_lib_agenda.py ├── test_lib_aha.py ├── test_lib_ast.py ├── test_lib_auth.py ├── test_lib_autodoc.py ├── test_lib_base.py ├── test_lib_boss.py ├── test_lib_cache.py ├── test_lib_cell.py ├── test_lib_certdir.py ├── test_lib_chop.py ├── test_lib_cli.py ├── test_lib_config.py ├── test_lib_const.py ├── test_lib_coro.py ├── test_lib_crypto_coin.py ├── test_lib_crypto_ecc.py ├── test_lib_crypto_passwd.py ├── test_lib_crypto_tinfoil.py ├── test_lib_datfile.py ├── test_lib_dyndeps.py ├── test_lib_encoding.py ├── test_lib_gis.py ├── test_lib_grammar.py ├── test_lib_hashitem.py ├── test_lib_hashset.py ├── test_lib_health.py ├── test_lib_hive.py ├── test_lib_httpapi.py ├── test_lib_interval.py ├── test_lib_json.py ├── test_lib_jsonstor.py ├── test_lib_layer.py ├── test_lib_link.py ├── test_lib_lmdbslab.py ├── test_lib_modelrev.py ├── test_lib_module.py ├── test_lib_msgpack.py ├── test_lib_multislabseqn.py ├── test_lib_nexus.py ├── test_lib_node.py ├── test_lib_output.py ├── test_lib_platforms_linux.py ├── test_lib_queue.py ├── test_lib_ratelimit.py ├── test_lib_reflect.py ├── test_lib_rstorm.py ├── test_lib_scope.py ├── test_lib_scrape.py ├── test_lib_slaboffs.py ├── test_lib_slabseqn.py ├── test_lib_snap.py ├── test_lib_spooled.py ├── test_lib_storm.py ├── test_lib_storm_format.py ├── test_lib_stormctrl.py ├── test_lib_stormhttp.py ├── test_lib_stormlib_aha.py ├── test_lib_stormlib_auth.py ├── test_lib_stormlib_backup.py ├── test_lib_stormlib_basex.py ├── test_lib_stormlib_cache.py ├── test_lib_stormlib_cell.py ├── test_lib_stormlib_compression.py ├── test_lib_stormlib_cortex.py ├── test_lib_stormlib_easyperm.py ├── test_lib_stormlib_env.py ├── test_lib_stormlib_ethereum.py ├── test_lib_stormlib_gen.py ├── test_lib_stormlib_gis.py ├── test_lib_stormlib_hashes.py ├── test_lib_stormlib_hex.py ├── test_lib_stormlib_imap.py ├── test_lib_stormlib_index.py ├── test_lib_stormlib_infosec.py ├── test_lib_stormlib_ipv6.py ├── test_lib_stormlib_iters.py ├── test_lib_stormlib_json.py ├── test_lib_stormlib_log.py ├── test_lib_stormlib_macro.py ├── test_lib_stormlib_mime.py ├── test_lib_stormlib_model.py ├── test_lib_stormlib_modelext.py ├── test_lib_stormlib_oauth.py ├── test_lib_stormlib_pack.py ├── test_lib_stormlib_random.py ├── test_lib_stormlib_scrape.py ├── test_lib_stormlib_smtp.py ├── test_lib_stormlib_spooled.py ├── test_lib_stormlib_stats.py ├── test_lib_stormlib_stix.py ├── test_lib_stormlib_storm.py ├── test_lib_stormlib_tabular.py ├── test_lib_stormlib_utils.py ├── test_lib_stormlib_vault.py ├── test_lib_stormlib_xml.py ├── test_lib_stormlib_yaml.py ├── test_lib_stormsvc.py ├── test_lib_stormtypes.py ├── test_lib_stormwhois.py ├── test_lib_structlog.py ├── test_lib_task.py ├── test_lib_thishost.py ├── test_lib_time.py ├── test_lib_trigger.py ├── test_lib_types.py ├── test_lib_urlhelp.py ├── test_lib_version.py ├── test_lib_view.py ├── test_lookup_iso3166.py ├── test_lookup_phonenum.py ├── test_mindmeld.py ├── test_model_auth.py ├── test_model_base.py ├── test_model_belief.py ├── test_model_biz.py ├── test_model_crypto.py ├── test_model_dns.py ├── test_model_doc.py ├── test_model_economic.py ├── test_model_entity.py ├── test_model_files.py ├── test_model_geopol.py ├── test_model_geospace.py ├── test_model_gov_cn.py ├── test_model_gov_intl.py ├── test_model_gov_us.py ├── test_model_inet.py ├── test_model_infotech.py ├── test_model_language.py ├── test_model_material.py ├── test_model_math.py ├── test_model_media.py ├── test_model_orgs.py ├── test_model_person.py ├── test_model_planning.py ├── test_model_proj.py ├── test_model_risk.py ├── test_model_science.py ├── test_model_syn.py ├── test_model_telco.py ├── test_model_transport.py ├── test_servers_axon.py ├── test_servers_cortex.py ├── test_servers_cryotank.py ├── test_servers_stemcell.py ├── test_servers_univ.py ├── test_telepath.py ├── test_tools_aha.py ├── test_tools_apikey.py ├── test_tools_autodoc.py ├── test_tools_axon2axon.py ├── test_tools_backup.py ├── test_tools_cellauth.py ├── test_tools_changelog.py ├── test_tools_cryo_cat.py ├── test_tools_cryo_list.py ├── test_tools_csvtool.py ├── test_tools_docker_validate.py ├── test_tools_easycert.py ├── test_tools_feed.py ├── test_tools_genpkg.py ├── test_tools_guid.py ├── test_tools_healthcheck.py ├── test_tools_hiveload.py ├── test_tools_hivesave.py ├── test_tools_json2mpk.py ├── test_tools_livebackup.py ├── test_tools_modrole.py ├── test_tools_moduser.py ├── test_tools_promote.py ├── test_tools_pullfile.py ├── test_tools_pushfile.py ├── test_tools_reload.py ├── test_tools_rstorm.py ├── test_tools_shutdown.py ├── test_tools_snapshot.py ├── test_tools_storm.py ├── test_utils.py ├── test_utils_getrefs.py ├── test_utils_stormcov.py └── utils.py ├── tools ├── __init__.py ├── aha │ ├── __init__.py │ ├── clone.py │ ├── easycert.py │ ├── enroll.py │ ├── list.py │ ├── mirror.py │ └── provision │ │ ├── __init__.py │ │ ├── service.py │ │ └── user.py ├── apikey.py ├── autodoc.py ├── axon2axon.py ├── backup.py ├── cellauth.py ├── changelog.py ├── cmdr.py ├── cryo │ ├── __init__.py │ ├── cat.py │ └── list.py ├── csvtool.py ├── docker │ ├── __init__.py │ └── validate.py ├── easycert.py ├── feed.py ├── genpkg.py ├── guid.py ├── healthcheck.py ├── hive │ ├── __init__.py │ ├── load.py │ └── save.py ├── json2mpk.py ├── livebackup.py ├── modrole.py ├── moduser.py ├── promote.py ├── pullfile.py ├── pushfile.py ├── reload.py ├── rstorm.py ├── shutdown.py ├── snapshot.py └── storm.py ├── utils ├── __init__.py ├── getrefs.py └── stormcov │ ├── __init__.py │ └── plugin.py └── vendor ├── __init__.py ├── cashaddress ├── LICENSE ├── __init__.py ├── base58.py ├── convert.py ├── crypto.py └── tests │ ├── __init__.py │ └── test_cashaddress.py ├── cpython ├── LICENSE ├── __init__.py └── lib │ ├── __init__.py │ ├── email │ ├── __init__.py │ ├── _parseaddr.py │ └── utils.py │ ├── http │ ├── __init__.py │ └── cookies.py │ ├── ipaddress.py │ ├── json.py │ └── test │ ├── __init__.py │ ├── support │ └── __init__.py │ ├── test_email │ ├── __init__.py │ ├── test_email.py │ └── test_utils.py │ ├── test_http_cookies.py │ ├── test_ipaddress.py │ └── test_json.py ├── substrateinterface ├── LICENSE ├── __init__.py ├── tests │ ├── __init__.py │ └── test_ss58.py └── utils │ ├── __init__.py │ └── ss58.py ├── utils.py └── xrpl ├── LICENSE ├── __init__.py ├── constants.py ├── core ├── __init__.py └── addresscodec │ ├── __init__.py │ ├── codec.py │ ├── exceptions.py │ ├── main.py │ └── utils.py └── tests ├── __init__.py ├── test_codec.py ├── test_main.py └── test_main_test_cases.py /.bumpversion.cfg: -------------------------------------------------------------------------------- 1 | [bumpversion] 2 | current_version = 2.213.0 3 | commit = True 4 | tag = True 5 | tag_message = 6 | 7 | [bumpversion:file:pyproject.toml] 8 | search = version = '{current_version}' 9 | replace = version = '{new_version}' 10 | 11 | [bumpversion:file:synapse/lib/version.py] 12 | serialize = {major}, {minor}, {patch} 13 | parse = (?P\d+),\s(?P\d+),\s(?P\d+) 14 | -------------------------------------------------------------------------------- /.coveragerc: -------------------------------------------------------------------------------- 1 | [report] 2 | omit = 3 | */synapse/tests/test_* 4 | 5 | ; Uncomment this section to enable code coverage of storm files in the 6 | ; storm_dirs directory listed below. This is disabled by default right now 7 | ; because it's pretty intensive and imposes a large perf hit on the already slow 8 | ; tests. 9 | ;[run] 10 | ;plugins = synapse.utils.stormcov 11 | 12 | [synapse.utils.stormcov] 13 | storm_dirs = synapse/assets/storm 14 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | # vim:set ft=gitignore: 2 | 3 | cells/ 4 | build/ 5 | localdata/ 6 | 7 | # Git / Editor / Coverage / Linter 8 | .git 9 | .gitignore 10 | .dockerignore 11 | .idea 12 | *.swo 13 | *.swp 14 | html/ 15 | htmlcov/ 16 | .coverage 17 | .coverage.* 18 | .coveragerc 19 | coverage.xml 20 | *,cover 21 | cover/ 22 | .pytest_cache/ 23 | .tox/ 24 | .cache 25 | nosetests.xml 26 | .mypy_cache/ 27 | 28 | # CI 29 | .appveyor.yml 30 | .bumpversion.cfg 31 | .circleci 32 | .pyup.yml 33 | 34 | # Synapse 35 | docs/ 36 | CHANGELOG.md 37 | Dockerfile 38 | 39 | # Python 40 | **/*.pyc 41 | **/__pycache__ 42 | build 43 | dist 44 | *.egg-info 45 | .eggs 46 | eggs/ 47 | *.egg 48 | venv 49 | .python-version 50 | .Python 51 | env/ 52 | develop-eggs/ 53 | downloads/ 54 | lib64/ 55 | parts/ 56 | sdist/ 57 | var/ 58 | *.manifest 59 | .installed.cfg 60 | *.spec 61 | pip-log.txt 62 | pip-delete-this-directory.txt 63 | *.mo 64 | *.pot 65 | *.log 66 | target/ 67 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "[BUG] " 5 | labels: needs triage 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior. Please include either repeatable steps or code that can be used to trigger the bug. Please include any associated trace backs and/or command line arguments used, if relevant. 15 | 16 | **Expected behavior** 17 | A clear and concise description of what you expected to happen. 18 | 19 | **Environment (please complete the following information):** 20 | - OS: [e.g. iOS] 21 | - Synapse Version [e.g. 22] 22 | - Python Version 23 | - Output of `python -m pip freeze` 24 | 25 | **Additional context** 26 | Add any other context about the problem here. 27 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: "[FEATURE] " 5 | labels: needs triage 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/workflows/git_sync.yaml: -------------------------------------------------------------------------------- 1 | name: GitSync 2 | 3 | on: 4 | - push 5 | - delete 6 | 7 | jobs: 8 | sync: 9 | runs-on: ubuntu-latest 10 | name: Git Repo Sync 11 | steps: 12 | - uses: actions/checkout@v2 13 | with: 14 | fetch-depth: 0 15 | - uses: vertexproject/git-repo-sync@v0.1.0 16 | with: 17 | target-url: https://${{ secrets.SYNC_TARGET_HOST }}/${{ github.repository }}.git 18 | target-username: ${{ secrets.SYNC_TARGET_USERNAME }} 19 | target-token: ${{ secrets.SYNC_TARGET_TOKEN }} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *.swp 5 | 6 | # sphinx API doc dir 7 | docs/synapse/autodocs 8 | 9 | # ipython checkpoints 10 | .ipynb_checkpoints 11 | 12 | # C extensions 13 | *.so 14 | 15 | # Distribution / packaging 16 | .Python 17 | env/ 18 | build/ 19 | develop-eggs/ 20 | dist/ 21 | downloads/ 22 | eggs/ 23 | .eggs/ 24 | lib64/ 25 | parts/ 26 | sdist/ 27 | var/ 28 | *.egg-info/ 29 | .installed.cfg 30 | *.egg 31 | 32 | # PyInstaller 33 | # Usually these files are written by a python script from a template 34 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 35 | *.manifest 36 | *.spec 37 | 38 | # Installer logs 39 | pip-log.txt 40 | pip-delete-this-directory.txt 41 | 42 | # Unit test / coverage reports 43 | .pytest_cache/ 44 | htmlcov/ 45 | html/ 46 | .tox/ 47 | .coverage 48 | .coverage.* 49 | .cache 50 | nosetests.xml 51 | coverage.xml 52 | *,cover 53 | cover/ 54 | 55 | # Translations 56 | *.mo 57 | *.pot 58 | 59 | # Django stuff: 60 | *.log 61 | 62 | # Sphinx documentation 63 | docs/_build/ 64 | 65 | # PyBuilder 66 | target/ 67 | 68 | # pyvenv 69 | venv 70 | 71 | # pyenv 72 | .python-version 73 | 74 | # PyCharm files. 75 | .idea/ 76 | 77 | # vim 78 | *.swo 79 | *.swp 80 | 81 | # Linter files 82 | .mypy_cache/ 83 | 84 | -------------------------------------------------------------------------------- /.pyup.yml: -------------------------------------------------------------------------------- 1 | # autogenerated pyup.io config file 2 | # see https://pyup.io/docs/configuration/ for all available options 3 | 4 | update: false 5 | -------------------------------------------------------------------------------- /.readthedocs.yaml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | build: 4 | os: ubuntu-22.04 5 | tools: 6 | python: "3.11" 7 | 8 | formats: 9 | - pdf 10 | - htmlzip 11 | 12 | sphinx: 13 | configuration: docs/conf.py 14 | 15 | python: 16 | install: 17 | - requirements: requirements_doc.txt 18 | -------------------------------------------------------------------------------- /changes/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/changes/.gitkeep -------------------------------------------------------------------------------- /changes/9f92991a0588f9631ecd85cc63c61ad0.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | desc: Updated Cortex Storm pool behavior to prefer all remote pool members before 3 | the local leader. 4 | prs: [] 5 | type: feat 6 | ... 7 | -------------------------------------------------------------------------------- /changes/ba56868fd6953c1b4488517a55393fc3.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | desc: Added CLI tool ``synapse.tools.shutdown`` to facilitate graceful shutdown of services 3 | by allowing them to complete current tasks. 4 | prs: [] 5 | type: feat 6 | ... 7 | -------------------------------------------------------------------------------- /changes/modelrefs/model_2.176.0_16ee721a6b7221344eaf946c3ab4602dda546b1a.yaml.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/changes/modelrefs/model_2.176.0_16ee721a6b7221344eaf946c3ab4602dda546b1a.yaml.gz -------------------------------------------------------------------------------- /changes/modelrefs/model_2.177.0_b7da795aeb690020e38e99dc5aa1f505cdc2d659.yaml.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/changes/modelrefs/model_2.177.0_b7da795aeb690020e38e99dc5aa1f505cdc2d659.yaml.gz -------------------------------------------------------------------------------- /changes/modelrefs/model_2.179.0_1c51c58523e9012655d8d18bfa1ad149e5536c25.yaml.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/changes/modelrefs/model_2.179.0_1c51c58523e9012655d8d18bfa1ad149e5536c25.yaml.gz -------------------------------------------------------------------------------- /changes/modelrefs/model_2.180.0_aecbb8c0839f3ad763076dd7acae968fae6ba8b7.yaml.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/changes/modelrefs/model_2.180.0_aecbb8c0839f3ad763076dd7acae968fae6ba8b7.yaml.gz -------------------------------------------------------------------------------- /changes/modelrefs/model_2.181.0_9241eebaad4a9c7bb007c6c5abb63be4e4ffac44.yaml.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/changes/modelrefs/model_2.181.0_9241eebaad4a9c7bb007c6c5abb63be4e4ffac44.yaml.gz -------------------------------------------------------------------------------- /changes/modelrefs/model_2.183.0_68e4f3dd36f4ff9dd7818ea2c8180b086092148f.yaml.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/changes/modelrefs/model_2.183.0_68e4f3dd36f4ff9dd7818ea2c8180b086092148f.yaml.gz -------------------------------------------------------------------------------- /changes/modelrefs/model_2.184.0_05940dce070d26f83bb7e4070f1d44d051804e3b.yaml.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/changes/modelrefs/model_2.184.0_05940dce070d26f83bb7e4070f1d44d051804e3b.yaml.gz -------------------------------------------------------------------------------- /changes/modelrefs/model_2.185.0_c2ef0eded02f8ac5f34704a117947f44095f41f4.yaml.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/changes/modelrefs/model_2.185.0_c2ef0eded02f8ac5f34704a117947f44095f41f4.yaml.gz -------------------------------------------------------------------------------- /changes/modelrefs/model_2.186.0_ffa4abc52513d4b8ac592496322227eed9e07dc5.yaml.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/changes/modelrefs/model_2.186.0_ffa4abc52513d4b8ac592496322227eed9e07dc5.yaml.gz -------------------------------------------------------------------------------- /changes/modelrefs/model_2.188.0_6d1f734406234e3750c72f5bf299f89a13d0825a.yaml.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/changes/modelrefs/model_2.188.0_6d1f734406234e3750c72f5bf299f89a13d0825a.yaml.gz -------------------------------------------------------------------------------- /changes/modelrefs/model_2.189.0_0cec341c3b35e19b0cb34c1d5210afb0790cba99.yaml.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/changes/modelrefs/model_2.189.0_0cec341c3b35e19b0cb34c1d5210afb0790cba99.yaml.gz -------------------------------------------------------------------------------- /changes/modelrefs/model_2.191.0_f6b07ada7cb68701e769e155735c9c004a404454.yaml.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/changes/modelrefs/model_2.191.0_f6b07ada7cb68701e769e155735c9c004a404454.yaml.gz -------------------------------------------------------------------------------- /changes/modelrefs/model_2.193.0_ad17bf2e740ba11453b7827ce70c140f969a1430.yaml.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/changes/modelrefs/model_2.193.0_ad17bf2e740ba11453b7827ce70c140f969a1430.yaml.gz -------------------------------------------------------------------------------- /changes/modelrefs/model_2.194.0_fb479d376805f963f11c5029310325c13ef2c883.yaml.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/changes/modelrefs/model_2.194.0_fb479d376805f963f11c5029310325c13ef2c883.yaml.gz -------------------------------------------------------------------------------- /changes/modelrefs/model_2.195.0_dc93864afdb2150e6d83ac4ed426c8e99bb3a448.yaml.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/changes/modelrefs/model_2.195.0_dc93864afdb2150e6d83ac4ed426c8e99bb3a448.yaml.gz -------------------------------------------------------------------------------- /changes/modelrefs/model_2.196.0_8182360d2ebf8e8bdd00cb72f03812061c819cc2.yaml.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/changes/modelrefs/model_2.196.0_8182360d2ebf8e8bdd00cb72f03812061c819cc2.yaml.gz -------------------------------------------------------------------------------- /changes/modelrefs/model_2.197.0_c8c758131cae47ef21e23ac8242012459ebfce9d.yaml.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/changes/modelrefs/model_2.197.0_c8c758131cae47ef21e23ac8242012459ebfce9d.yaml.gz -------------------------------------------------------------------------------- /changes/modelrefs/model_2.198.0_047e5e996d0bcaad4ada4ea390a726aca1abba9b.yaml.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/changes/modelrefs/model_2.198.0_047e5e996d0bcaad4ada4ea390a726aca1abba9b.yaml.gz -------------------------------------------------------------------------------- /changes/modelrefs/model_2.201.0_eed8c13ff316a77ae835539215c862d052d31994.yaml.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/changes/modelrefs/model_2.201.0_eed8c13ff316a77ae835539215c862d052d31994.yaml.gz -------------------------------------------------------------------------------- /changes/modelrefs/model_2.203.0_809ecdca2e2b05f1cd111bb23c237127b2b9c177.yaml.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/changes/modelrefs/model_2.203.0_809ecdca2e2b05f1cd111bb23c237127b2b9c177.yaml.gz -------------------------------------------------------------------------------- /changes/modelrefs/model_2.204.0_6b616fcd2d70a036d9853355fcb6fd491e84f015.yaml.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/changes/modelrefs/model_2.204.0_6b616fcd2d70a036d9853355fcb6fd491e84f015.yaml.gz -------------------------------------------------------------------------------- /changes/modelrefs/model_2.205.0_d985f8b93669529b2d90895baabb1dc289e287df.yaml.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/changes/modelrefs/model_2.205.0_d985f8b93669529b2d90895baabb1dc289e287df.yaml.gz -------------------------------------------------------------------------------- /changes/modelrefs/model_2.206.0_0be7ce9e061b2c752fb454adb50c5267cc14fdfe.yaml.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/changes/modelrefs/model_2.206.0_0be7ce9e061b2c752fb454adb50c5267cc14fdfe.yaml.gz -------------------------------------------------------------------------------- /changes/modelrefs/model_2.210.0_e43efa9d9c2257ff05fe47988a323e16896fdf50.yaml.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/changes/modelrefs/model_2.210.0_e43efa9d9c2257ff05fe47988a323e16896fdf50.yaml.gz -------------------------------------------------------------------------------- /changes/modelrefs/model_2.211.0_99beab651131ab996a967c6d0345c80b89de4a74.yaml.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/changes/modelrefs/model_2.211.0_99beab651131ab996a967c6d0345c80b89de4a74.yaml.gz -------------------------------------------------------------------------------- /changes/modelrefs/model_2.212.0_68ec8184b0e2469fd1ef30cbeb29f5989c60c768.yaml.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/changes/modelrefs/model_2.212.0_68ec8184b0e2469fd1ef30cbeb29f5989c60c768.yaml.gz -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | codecov: 2 | notify: 3 | after_n_builds: 1 4 | 5 | coverage: 6 | status: 7 | project: 8 | default: 9 | threshold: 1% 10 | patch: 11 | default: 12 | target: 96% 13 | 14 | comment: 15 | after_n_builds: 1 16 | -------------------------------------------------------------------------------- /conftest.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import warnings 4 | 5 | import synapse.common as s_common 6 | 7 | THROW = False 8 | 9 | def audithook(event, args): 10 | if event == 'socket.bind': 11 | _, addr = args 12 | if isinstance(addr, tuple) and (port := addr[1]) != 0: 13 | 14 | testname = os.environ.get('PYTEST_CURRENT_TEST', '').split(' ')[0] 15 | 16 | mesg = f'Synapse tests should not bind to fixed ports: {testname=} {port=}' 17 | warnings.warn(mesg) 18 | 19 | if THROW: 20 | raise RuntimeError(mesg) 21 | 22 | def pytest_sessionstart(session): 23 | if s_common.envbool('SYNDEV_AUDIT_PORT_BINDS'): 24 | sys.addaudithook(audithook) 25 | 26 | if s_common.envbool('SYNDEV_AUDIT_PORT_BINDS_RAISE'): 27 | global THROW 28 | THROW = True 29 | -------------------------------------------------------------------------------- /docker/README.rst: -------------------------------------------------------------------------------- 1 | Synapse Docker Builds 2 | ===================== 3 | 4 | See https://synapse.docs.vertex.link/en/latest/synapse/devguides/docker.html for information about Docker container 5 | builds. 6 | -------------------------------------------------------------------------------- /docker/bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -d /build/synapse ]; then 4 | PIP_NO_CACHE_DIR=1 PIP_ROOT_USER_ACTION=ignore python -m pip install --verbose --break-system-packages /build/synapse 5 | fi 6 | 7 | if [ -f /build/synapse/rmlist.txt ]; then 8 | while read path; do 9 | if [ -e $path ]; then 10 | echo "Removing ${path}" && rm -rf $path; 11 | else 12 | echo "! Path not present: ${path}"; 13 | exit 1 14 | fi 15 | done < /build/synapse/rmlist.txt 16 | fi 17 | 18 | rm -rf /build 19 | -------------------------------------------------------------------------------- /docker/build_all.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | # 5 | # Build and tag the suite of synapse images. 6 | # 7 | # This is expected to be executed from the root of the repository; eg: 8 | # 9 | # ./docker/build_all.sh 10 | # 11 | # The first argument may be provided, including the tag to build. 12 | # A default tag will be used if one is not provided. 13 | # 14 | ############################################################################## 15 | 16 | set -e # exit on nonzero 17 | set -u # undefined variables 18 | set -o pipefail # pipefail propagate error codes 19 | set -x # debugging 20 | 21 | TAG=${1:-} 22 | 23 | [ ! $TAG ] && echo "Tag not provided, defaulting tag to dev_build" && TAG=dev_build 24 | 25 | # Build target images 26 | docker builder prune -a -f 27 | docker build --no-cache --progress plain --pull -t vertexproject/synapse:$TAG -f docker/images/synapse/Dockerfile . 28 | docker/build_image.sh aha $TAG 29 | docker/build_image.sh axon $TAG 30 | docker/build_image.sh cortex $TAG 31 | docker/build_image.sh cryotank $TAG 32 | docker/build_image.sh jsonstor $TAG 33 | docker/build_image.sh stemcell $TAG 34 | -------------------------------------------------------------------------------- /docker/build_image.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | # 5 | # Build and tag a specific synapse image. 6 | # 7 | # This is expected to be executed from the root of the repository; eg: 8 | # 9 | # ./docker/build_image.sh cortex 10 | # 11 | # The first argument is the server (in docker/images) to build. 12 | # A second argument may be provided, including the tag to build. 13 | # A default tag will be used if one is not provided. 14 | # 15 | # This will build a base image, if it does not exist, using the 16 | # ./docker/build_base.sh script. 17 | # 18 | ############################################################################## 19 | 20 | set -e # exit on nonzero 21 | set -u # undefined variables 22 | set -o pipefail # pipefail propagate error codes 23 | # set -x # debugging 24 | 25 | IMAGE=${1:-} 26 | if [ ${IMAGE} == "synapse" ] 27 | then 28 | echo "The vertexproject/synapse image is not built with this script." 29 | false 30 | fi 31 | IMAGE_DIR=docker/images/${IMAGE} 32 | [ ! -d $IMAGE_DIR ] && echo "$IMAGE_DIR does not exist." && false 33 | 34 | TAG=${2:-} 35 | 36 | [ ! $TAG ] && echo "Tag not provided, defaulting tag to dev_build" && TAG=dev_build 37 | 38 | # Build target image 39 | echo "Building from docker/images/$IMAGE/Dockerfile" 40 | docker builder prune -a -f 41 | docker build --no-cache --progress plain --pull -t vertexproject/synapse-$IMAGE:$TAG -f docker/images/$IMAGE/Dockerfile . 42 | -------------------------------------------------------------------------------- /docker/images/aha/Dockerfile: -------------------------------------------------------------------------------- 1 | # vim:set ft=dockerfile: 2 | FROM vertexproject/vtx-base-image:py311 3 | 4 | COPY synapse /build/synapse/synapse 5 | COPY README.rst /build/synapse/README.rst 6 | COPY pyproject.toml /build/synapse/pyproject.toml 7 | 8 | COPY docker/rmlist.txt /build/synapse/rmlist.txt 9 | COPY docker/bootstrap.sh /build/synapse/bootstrap.sh 10 | COPY docker/images/aha/entrypoint.sh /vertex/synapse/entrypoint.sh 11 | 12 | RUN /build/synapse/bootstrap.sh 13 | 14 | EXPOSE 4443 15 | EXPOSE 27492 16 | 17 | VOLUME /vertex/storage 18 | 19 | ENTRYPOINT ["tini", "--", "/vertex/synapse/entrypoint.sh"] 20 | 21 | HEALTHCHECK --start-period=10s --retries=1 --timeout=10s --interval=30s CMD python -m synapse.tools.healthcheck -c cell:///vertex/storage/ 22 | -------------------------------------------------------------------------------- /docker/images/aha/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PREBOOT_SCRIPT=/vertex/boothooks/preboot.sh 4 | CONCURRENT_SCRIPT=/vertex/boothooks/concurrent.sh 5 | 6 | if [ -f $PREBOOT_SCRIPT ] 7 | then 8 | echo "Executing $PREBOOT_SCRIPT" 9 | ./$PREBOOT_SCRIPT 10 | if [ $? -ne 0 ] 11 | then 12 | echo "$PREBOOT_SCRIPT script failed with return value $?" 13 | exit 1 14 | fi 15 | fi 16 | 17 | if [ -f $CONCURRENT_SCRIPT ] 18 | then 19 | echo "Executing and backgrounding $CONCURRENT_SCRIPT" 20 | ./$CONCURRENT_SCRIPT & 21 | fi 22 | 23 | exec python -O -m synapse.servers.aha /vertex/storage 24 | -------------------------------------------------------------------------------- /docker/images/axon/Dockerfile: -------------------------------------------------------------------------------- 1 | # vim:set ft=dockerfile: 2 | FROM vertexproject/vtx-base-image:py311 3 | 4 | COPY synapse /build/synapse/synapse 5 | COPY README.rst /build/synapse/README.rst 6 | COPY pyproject.toml /build/synapse/pyproject.toml 7 | 8 | COPY docker/rmlist.txt /build/synapse/rmlist.txt 9 | COPY docker/bootstrap.sh /build/synapse/bootstrap.sh 10 | COPY docker/images/axon/entrypoint.sh /vertex/synapse/entrypoint.sh 11 | 12 | RUN /build/synapse/bootstrap.sh 13 | 14 | EXPOSE 4443 15 | EXPOSE 27492 16 | 17 | VOLUME /vertex/storage 18 | 19 | ENTRYPOINT ["tini", "--", "/vertex/synapse/entrypoint.sh"] 20 | 21 | HEALTHCHECK --start-period=10s --retries=1 --timeout=10s --interval=30s CMD python -m synapse.tools.healthcheck -c cell:///vertex/storage/ 22 | -------------------------------------------------------------------------------- /docker/images/axon/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PREBOOT_SCRIPT=/vertex/boothooks/preboot.sh 4 | CONCURRENT_SCRIPT=/vertex/boothooks/concurrent.sh 5 | 6 | if [ -f $PREBOOT_SCRIPT ] 7 | then 8 | echo "Executing $PREBOOT_SCRIPT" 9 | ./$PREBOOT_SCRIPT 10 | if [ $? -ne 0 ] 11 | then 12 | echo "$PREBOOT_SCRIPT script failed with return value $?" 13 | exit 1 14 | fi 15 | fi 16 | 17 | if [ -f $CONCURRENT_SCRIPT ] 18 | then 19 | echo "Executing and backgrounding $CONCURRENT_SCRIPT" 20 | ./$CONCURRENT_SCRIPT & 21 | fi 22 | 23 | 24 | exec python -O -m synapse.servers.axon /vertex/storage 25 | -------------------------------------------------------------------------------- /docker/images/cortex/Dockerfile: -------------------------------------------------------------------------------- 1 | # vim:set ft=dockerfile: 2 | FROM vertexproject/vtx-base-image:py311 3 | 4 | COPY synapse /build/synapse/synapse 5 | COPY README.rst /build/synapse/README.rst 6 | COPY pyproject.toml /build/synapse/pyproject.toml 7 | 8 | COPY docker/rmlist.txt /build/synapse/rmlist.txt 9 | COPY docker/bootstrap.sh /build/synapse/bootstrap.sh 10 | COPY docker/images/cortex/entrypoint.sh /vertex/synapse/entrypoint.sh 11 | 12 | RUN /build/synapse/bootstrap.sh 13 | 14 | EXPOSE 4443 15 | EXPOSE 27492 16 | 17 | VOLUME /vertex/storage 18 | 19 | ENTRYPOINT ["tini", "--", "/vertex/synapse/entrypoint.sh"] 20 | 21 | HEALTHCHECK --start-period=10s --retries=1 --timeout=10s --interval=30s CMD python -m synapse.tools.healthcheck -c cell:///vertex/storage/ 22 | -------------------------------------------------------------------------------- /docker/images/cortex/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PREBOOT_SCRIPT=/vertex/boothooks/preboot.sh 4 | CONCURRENT_SCRIPT=/vertex/boothooks/concurrent.sh 5 | 6 | if [ -f $PREBOOT_SCRIPT ] 7 | then 8 | echo "Executing $PREBOOT_SCRIPT" 9 | ./$PREBOOT_SCRIPT 10 | if [ $? -ne 0 ] 11 | then 12 | echo "$PREBOOT_SCRIPT script failed with return value $?" 13 | exit 1 14 | fi 15 | fi 16 | 17 | if [ -f $CONCURRENT_SCRIPT ] 18 | then 19 | echo "Executing and backgrounding $CONCURRENT_SCRIPT" 20 | ./$CONCURRENT_SCRIPT & 21 | fi 22 | 23 | 24 | exec python -O -m synapse.servers.cortex /vertex/storage 25 | -------------------------------------------------------------------------------- /docker/images/cryotank/Dockerfile: -------------------------------------------------------------------------------- 1 | # vim:set ft=dockerfile: 2 | FROM vertexproject/vtx-base-image:py311 3 | 4 | COPY synapse /build/synapse/synapse 5 | COPY README.rst /build/synapse/README.rst 6 | COPY pyproject.toml /build/synapse/pyproject.toml 7 | 8 | COPY docker/rmlist.txt /build/synapse/rmlist.txt 9 | COPY docker/bootstrap.sh /build/synapse/bootstrap.sh 10 | COPY docker/images/cryotank/entrypoint.sh /vertex/synapse/entrypoint.sh 11 | 12 | RUN /build/synapse/bootstrap.sh 13 | 14 | EXPOSE 4443 15 | EXPOSE 27492 16 | 17 | VOLUME /vertex/storage 18 | 19 | ENTRYPOINT ["tini", "--", "/vertex/synapse/entrypoint.sh"] 20 | 21 | HEALTHCHECK --start-period=10s --retries=1 --timeout=10s --interval=30s CMD python -m synapse.tools.healthcheck -c cell:///vertex/storage/ 22 | -------------------------------------------------------------------------------- /docker/images/cryotank/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PREBOOT_SCRIPT=/vertex/boothooks/preboot.sh 4 | CONCURRENT_SCRIPT=/vertex/boothooks/concurrent.sh 5 | 6 | if [ -f $PREBOOT_SCRIPT ] 7 | then 8 | echo "Executing $PREBOOT_SCRIPT" 9 | ./$PREBOOT_SCRIPT 10 | if [ $? -ne 0 ] 11 | then 12 | echo "$PREBOOT_SCRIPT script failed with return value $?" 13 | exit 1 14 | fi 15 | fi 16 | 17 | if [ -f $CONCURRENT_SCRIPT ] 18 | then 19 | echo "Executing and backgrounding $CONCURRENT_SCRIPT" 20 | ./$CONCURRENT_SCRIPT & 21 | fi 22 | 23 | 24 | exec python -O -m synapse.servers.cryotank /vertex/storage 25 | -------------------------------------------------------------------------------- /docker/images/jsonstor/Dockerfile: -------------------------------------------------------------------------------- 1 | # vim:set ft=dockerfile: 2 | FROM vertexproject/vtx-base-image:py311 3 | 4 | COPY synapse /build/synapse/synapse 5 | COPY README.rst /build/synapse/README.rst 6 | COPY pyproject.toml /build/synapse/pyproject.toml 7 | 8 | COPY docker/rmlist.txt /build/synapse/rmlist.txt 9 | COPY docker/bootstrap.sh /build/synapse/bootstrap.sh 10 | COPY docker/images/jsonstor/entrypoint.sh /vertex/synapse/entrypoint.sh 11 | 12 | RUN /build/synapse/bootstrap.sh 13 | 14 | EXPOSE 4443 15 | EXPOSE 27492 16 | 17 | VOLUME /vertex/storage 18 | 19 | ENTRYPOINT ["tini", "--", "/vertex/synapse/entrypoint.sh"] 20 | 21 | HEALTHCHECK --start-period=10s --retries=1 --timeout=10s --interval=30s CMD python -m synapse.tools.healthcheck -c cell:///vertex/storage/ 22 | -------------------------------------------------------------------------------- /docker/images/jsonstor/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PREBOOT_SCRIPT=/vertex/boothooks/preboot.sh 4 | CONCURRENT_SCRIPT=/vertex/boothooks/concurrent.sh 5 | 6 | if [ -f $PREBOOT_SCRIPT ] 7 | then 8 | echo "Executing $PREBOOT_SCRIPT" 9 | ./$PREBOOT_SCRIPT 10 | if [ $? -ne 0 ] 11 | then 12 | echo "$PREBOOT_SCRIPT script failed with return value $?" 13 | exit 1 14 | fi 15 | fi 16 | 17 | if [ -f $CONCURRENT_SCRIPT ] 18 | then 19 | echo "Executing and backgrounding $CONCURRENT_SCRIPT" 20 | ./$CONCURRENT_SCRIPT & 21 | fi 22 | 23 | 24 | exec python -O -m synapse.servers.jsonstor /vertex/storage 25 | -------------------------------------------------------------------------------- /docker/images/stemcell/Dockerfile: -------------------------------------------------------------------------------- 1 | # vim:set ft=dockerfile: 2 | FROM vertexproject/vtx-base-image:py311 3 | 4 | COPY synapse /build/synapse/synapse 5 | COPY README.rst /build/synapse/README.rst 6 | COPY pyproject.toml /build/synapse/pyproject.toml 7 | 8 | COPY docker/rmlist.txt /build/synapse/rmlist.txt 9 | COPY docker/bootstrap.sh /build/synapse/bootstrap.sh 10 | COPY docker/images/stemcell/entrypoint.sh /vertex/synapse/entrypoint.sh 11 | 12 | RUN /build/synapse/bootstrap.sh 13 | 14 | EXPOSE 4443 15 | EXPOSE 27492 16 | 17 | VOLUME /vertex/storage 18 | 19 | ENTRYPOINT ["tini", "--", "/vertex/synapse/entrypoint.sh"] 20 | 21 | HEALTHCHECK --start-period=10s --retries=1 --timeout=10s --interval=30s CMD python -m synapse.tools.healthcheck -c cell:///vertex/storage/ 22 | -------------------------------------------------------------------------------- /docker/images/stemcell/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PREBOOT_SCRIPT=/vertex/boothooks/preboot.sh 4 | CONCURRENT_SCRIPT=/vertex/boothooks/concurrent.sh 5 | 6 | if [ -f $PREBOOT_SCRIPT ] 7 | then 8 | echo "Executing $PREBOOT_SCRIPT" 9 | ./$PREBOOT_SCRIPT 10 | if [ $? -ne 0 ] 11 | then 12 | echo "$PREBOOT_SCRIPT script failed with return value $?" 13 | exit 1 14 | fi 15 | fi 16 | 17 | if [ -f $CONCURRENT_SCRIPT ] 18 | then 19 | echo "Executing and backgrounding $CONCURRENT_SCRIPT" 20 | ./$CONCURRENT_SCRIPT & 21 | fi 22 | 23 | 24 | exec python -O -m synapse.servers.stemcell /vertex/storage 25 | -------------------------------------------------------------------------------- /docker/images/synapse/Dockerfile: -------------------------------------------------------------------------------- 1 | # vim:set ft=dockerfile: 2 | 3 | # This image is only a reference image to use as a base image with 4 | # synapse and its dependencies pre-installed. It does not start any 5 | # services. 6 | 7 | FROM vertexproject/vtx-base-image:py311 8 | 9 | ENV SYN_LOG_LEVEL="INFO" 10 | 11 | COPY synapse /build/synapse/synapse 12 | COPY README.rst /build/synapse/README.rst 13 | COPY pyproject.toml /build/synapse/pyproject.toml 14 | 15 | COPY docker/rmlist.txt /build/synapse/rmlist.txt 16 | COPY docker/bootstrap.sh /build/synapse/bootstrap.sh 17 | RUN /build/synapse/bootstrap.sh 18 | 19 | VOLUME /vertex/storage 20 | -------------------------------------------------------------------------------- /docker/rmlist.txt: -------------------------------------------------------------------------------- 1 | /usr/local/lib/python3.11/site-packages/synapse/tests/files/certdir/ 2 | /usr/local/lib/python3.11/site-packages/synapse/tests/files/aha/certs/ 3 | -------------------------------------------------------------------------------- /docs/404.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | .. _synapse-404: 4 | 5 | 404 6 | === 7 | 8 | We're sorry! The page you are looking for could not be found! Use the search bar or the index on the left to find what 9 | you are looking for. 10 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | SOURCEDIR = . 8 | BUILDDIR = _build 9 | 10 | # Put it first so that "make" without argument is like "make help". 11 | help: 12 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 13 | 14 | .PHONY: help Makefile 15 | 16 | # Catch-all target: route all unknown targets to Sphinx using the new 17 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 18 | %: Makefile 19 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -------------------------------------------------------------------------------- /docs/_static/css/theme_overrides.css: -------------------------------------------------------------------------------- 1 | /* Set the page width to 90% of the users screen. */ 2 | .wy-nav-content { 3 | max-width: 90%; 4 | } 5 | 6 | /* provide a tight table option */ 7 | .tight-table td { 8 | white-space: normal !important; 9 | } 10 | 11 | /* Set search window background color to VTX GRAY1 */ 12 | .wy-side-nav-search { 13 | background-color: #333F48; 14 | } 15 | 16 | .wy-side-scroll { 17 | background-color: #333F48; 18 | } 19 | 20 | .wy-nav-side { 21 | background-color: #333F48; 22 | } 23 | 24 | /* Use VTX Gray 2 for the versions selection */ 25 | 26 | .rst-versions { 27 | background-color: #5B6770; 28 | } 29 | 30 | .rst-versions .rst-current-version { 31 | background-color: #5B6770; 32 | } 33 | 34 | /* Set the logo size */ 35 | .wy-side-nav-search>a img.logo { 36 | width: fit-content; 37 | } 38 | 39 | /* Set the caption headers to vertex green */ 40 | .wy-menu-vertical header, .wy-menu-vertical p.caption { 41 | color: #00A000; 42 | } 43 | 44 | /* Hide "On GitHub" section from versions menu - 3 is a magic number, see the following for details 45 | https://docs.readthedocs.io/en/stable/guides/remove-edit-buttons.html 46 | */ 47 | div.rst-versions > div.rst-other-versions > div.injected > dl:nth-child(3) { 48 | display: none; 49 | } 50 | -------------------------------------------------------------------------------- /docs/_static/favicon.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/_templates/breadcrumbs.html: -------------------------------------------------------------------------------- 1 | {%- extends "sphinx_rtd_theme/breadcrumbs.html" %} 2 | 3 | {% block breadcrumbs_aside %} 4 | {% endblock %} 5 | -------------------------------------------------------------------------------- /docs/docdata/README.txt: -------------------------------------------------------------------------------- 1 | This directory contains data used for documentation purposes. 2 | -------------------------------------------------------------------------------- /docs/docdata/foopkg/foopkg.yml: -------------------------------------------------------------------------------- 1 | name: foopkg 2 | version: 1.0.0 3 | synapse_version: '>=2.144.0,<3.0.0' 4 | 5 | onload: $lib.import(foomod).onload() 6 | 7 | modules: 8 | - name: foomod 9 | modconf: 10 | srcguid: f751f9ad20e75547be230ae1a425fb9f 11 | 12 | commands: 13 | - name: foocmd 14 | descr: | 15 | One line description on the first line. 16 | Followed by a more detailed description talking about what the command does and any 17 | useful additional information. 18 | 19 | Examples: 20 | # A couple examples of the command 21 | inet:ipv4 | foocmd 22 | inet:ipv4 | limit 1 | foocmd --yield 23 | asroot: true 24 | cmdargs: 25 | - - --debug 26 | - default: false 27 | action: store_true 28 | help: Show verbose debug output. 29 | 30 | - - --yield 31 | - default: false 32 | action: store_true 33 | help: Yield the newly created nodes. 34 | 35 | - - --timeout 36 | - default: 0 37 | type: int 38 | help: Specify a timeout in seconds. 39 | cmdconf: 40 | srcguid: f751f9ad20e75547be230ae1a425fb9f 41 | cmdinputs: 42 | - form: inet:ipv4 43 | -------------------------------------------------------------------------------- /docs/docdata/foopkg/storm/commands/foocmd: -------------------------------------------------------------------------------- 1 | $foo = $lib.import(foomod) 2 | 3 | [:asn = $foo.bar(:asn, $(20))] 4 | 5 | $node.data.set(foodata, $lib.time.now()) 6 | -------------------------------------------------------------------------------- /docs/docdata/foopkg/storm/modules/foomod: -------------------------------------------------------------------------------- 1 | function onload() { 2 | [ meta:source=$modconf.srcguid 3 | :name="foomod" 4 | :type="foo" 5 | ] 6 | fini { return($lib.null) } 7 | } 8 | 9 | function bar(x, y) { 10 | return ($($x + $y)) 11 | } 12 | -------------------------------------------------------------------------------- /docs/docdata/foopkg/storm/optic/index.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/docs/docdata/foopkg/storm/optic/index.html -------------------------------------------------------------------------------- /docs/docdata/mastering_example_ingest.json: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | [ 4 | "inet:ipv4", 5 | 1 6 | ], 7 | { 8 | "tags": { 9 | "example": [ 10 | null, 11 | null 12 | ] 13 | } 14 | } 15 | ], 16 | [ 17 | [ 18 | "inet:fqdn", 19 | "woot.com" 20 | ], 21 | { 22 | "tags": { 23 | "example": [ 24 | null, 25 | null 26 | ] 27 | } 28 | } 29 | ] 30 | ] 31 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. Synapse documentation master file, created by 2 | sphinx-quickstart on Wed Jun 10 23:31:34 2020. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to the Synapse documentation! 7 | ===================================== 8 | 9 | `Star us on GitHub `__ \| `Watch Synapse 101 `__ 10 | 11 | .. toctree:: 12 | :maxdepth: 2 13 | :caption: Contents: 14 | 15 | synapse/intro 16 | synapse/quickstart 17 | 18 | synapse/userguide 19 | synapse/adminguide 20 | synapse/deploymentguide 21 | synapse/devopsguide 22 | synapse/devguide 23 | synapse/glossary 24 | synapse/contributing 25 | 26 | synapse/apidocs 27 | synapse/httpapi 28 | 29 | synapse/datamodel 30 | synapse/stormtypes 31 | 32 | synapse/power_ups 33 | synapse/user_interface 34 | 35 | synapse/support 36 | 37 | synapse/changelog 38 | 39 | Indices and tables 40 | ================== 41 | 42 | * :ref:`genindex` 43 | * :ref:`modindex` 44 | * :ref:`search` 45 | -------------------------------------------------------------------------------- /docs/synapse/apidocs.rst: -------------------------------------------------------------------------------- 1 | .. _apidocs: 2 | 3 | Synapse Python API 4 | ================== 5 | 6 | .. toctree:: 7 | :maxdepth: 4 8 | 9 | autodocs/synapse 10 | -------------------------------------------------------------------------------- /docs/synapse/changelog.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../../CHANGELOG.rst 2 | -------------------------------------------------------------------------------- /docs/synapse/contributing.rst: -------------------------------------------------------------------------------- 1 | Synapse Contributors Guide 2 | ########################## 3 | 4 | This Contributors Guide is written for people who will be working on the 5 | Synapse code base, contributing to it via code patches, or maintaining written 6 | documentation. 7 | 8 | The Contributors Guide is a living document and will continue to be updated 9 | and expanded. The current sections are: 10 | 11 | .. toctree:: 12 | :titlesonly: 13 | 14 | contributing/contributing 15 | contributing/doc_mastering 16 | contributing/release_process 17 | 18 | .. _index: ../index.html 19 | -------------------------------------------------------------------------------- /docs/synapse/datamodel.rst: -------------------------------------------------------------------------------- 1 | .. _dm-index: 2 | 3 | Synapse Data Model 4 | ################## 5 | 6 | This contains documentation for Synapse Data Model, including the data model deprecation policy. 7 | 8 | The current sections are: 9 | 10 | .. toctree:: 11 | :titlesonly: 12 | 13 | autodocs/datamodel_types 14 | autodocs/datamodel_forms 15 | 16 | datamodel_deprecation 17 | -------------------------------------------------------------------------------- /docs/synapse/devguide.rst: -------------------------------------------------------------------------------- 1 | .. _devguide: 2 | 3 | Synapse Developer Guide 4 | ####################### 5 | 6 | This Dev Guide is written by and for Synapse developers. 7 | 8 | .. note:: 9 | 10 | Synapse as a library is under constant development. It is posssible that content here may become out of date. If 11 | you encounter issues with documentation in the Developers guides, please reach out to us on our Synapse `Slack`_ 12 | chat or file an issue in our projects Github page. 13 | 14 | The Dev Guide is a living document and will continue to be updated and expanded as appropriate. The current sections are: 15 | 16 | .. toctree:: 17 | :titlesonly: 18 | 19 | devguides/power-ups 20 | devguides/architecture 21 | devguides/docker 22 | devguides/adv_power_ups 23 | devguides/storm_api 24 | 25 | .. _Slack: https://v.vtx.lk/join-slack 26 | -------------------------------------------------------------------------------- /docs/synapse/devguides/adduserimage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Add a user to a debian based container with an arbitrary uid/gid value. 3 | # default username: altuser 4 | # default uid: 8888 5 | 6 | set -e 7 | 8 | if [ -z $1 ] 9 | then 10 | echo "Usage: srcImage name id suffix" 11 | echo "srcImage required." 12 | exit 1 13 | fi 14 | 15 | SRC_IMAGE_NAME=$1 16 | NEW_NAME=${2:-altuser} 17 | NEW_ID=${3:-8888} 18 | SUFFIX=-${4:-$NEW_NAME} 19 | 20 | echo "Add user/group ${NEW_NAME} with ${NEW_ID} into ${SRC_IMAGE_NAME}, creating: ${SRC_IMAGE_NAME}${SUFFIX}" 21 | 22 | printf "FROM $SRC_IMAGE_NAME \ 23 | \nRUN set -ex \\ 24 | && groupadd -g $NEW_ID $NEW_NAME \\ 25 | && useradd -r --home-dir=/home/$NEW_NAME -u $NEW_ID -g $NEW_NAME --shell /bin/bash $NEW_NAME \\ 26 | && mkdir -p /home/$NEW_NAME \\ 27 | && chown $NEW_ID:$NEW_ID /home/$NEW_NAME\n" > ./Dockerfile 28 | 29 | docker build -t $SRC_IMAGE_NAME$SUFFIX -f ./Dockerfile . 30 | 31 | rm ./Dockerfile 32 | 33 | exit 0 34 | -------------------------------------------------------------------------------- /docs/synapse/devguides/adv_power_ups.rst: -------------------------------------------------------------------------------- 1 | .. toctree:: 2 | :titlesonly: 3 | 4 | .. _dev_adv_power_ups: 5 | 6 | Advanced Power-Up Development 7 | ############################# 8 | 9 | An Advanced Power-Up is standalone application that extends the capabilities of the Cortex 10 | by implementing a Storm Service (see :ref:`gloss-service`). 11 | One common use case for creating an Advanced Power-Up is to add a Storm command that will run custom Python 12 | to parse a file, translate the results into the Synapse datamodel, and then ingest them into the hypergraph. 13 | 14 | In order to leverage core functionalities it is recommended that Storm services are created as Cell implementations. 15 | For additional details see the `advanced-power-example repository`_, which contains an example that can be used 16 | as a reference for building an Advanced Power-Up. 17 | 18 | .. _advanced-power-example repository: https://github.com/vertexproject/advanced-powerup-example 19 | -------------------------------------------------------------------------------- /docs/synapse/support.rst: -------------------------------------------------------------------------------- 1 | .. _synapse-support: 2 | 3 | Synapse Support 4 | =============== 5 | 6 | Information for Vertex support. 7 | 8 | 9 | Slack 10 | ----- 11 | 12 | Best effort chat based support is available through the `Synapse Slack`_. You can find Vertex Project analysts, 13 | engineers, and other users who can help with questions you may have. 14 | 15 | 16 | Service Desk 17 | ------------ 18 | 19 | Commercial customers have access to the Vertex Support `Service Desk`_. This is the ideal place for customers to 20 | submit issues, modeling questions, and feature requests. 21 | 22 | .. _Service Desk: https://vertexproject.atlassian.net/servicedesk/customer/portals 23 | .. _Synapse Slack: https://v.vtx.lk/join-slack 24 | -------------------------------------------------------------------------------- /docs/synapse/user_interface.rst: -------------------------------------------------------------------------------- 1 | .. _synapse-ui: 2 | 3 | Synapse User Interface 4 | ====================== 5 | 6 | Optic (the Synapse UI) is part of `The Vertex Project `_'s commercial offering, Synapse Enterprise. Synapse Enterprise is an on-premises solution that includes `Optic `_ and all of the Power-Ups. The license includes unlimited users and does not limit the amount of data or number of instances you deploy. We take a white-glove approach to each deployment where we're with you every step of the way from planning deployment sizes to helping to train your analysts. 7 | 8 | Feel free to `contact us `_ or `request a demo instance `_. 9 | 10 | For additional information see the `Optic Documentation `_. 11 | -------------------------------------------------------------------------------- /docs/synapse/userguide.rst: -------------------------------------------------------------------------------- 1 | .. _userguide: 2 | 3 | Synapse User Guide 4 | ################## 5 | 6 | This User Guide is written by and for Synapse users and is intended to provide a general overview of 7 | Synapse concepts and operations. Technical documentation appropriate for Synapse deployment and 8 | development can be found elsewhere in the Document Index_. 9 | 10 | The User Guide is a living document and will continue to be updated and expanded as appropriate. The 11 | current sections are: 12 | 13 | .. toctree:: 14 | :maxdepth: 1 15 | :caption: Contents: 16 | 17 | userguides/background 18 | userguides/data_model 19 | userguides/analytical_model 20 | userguides/views_layers 21 | userguides/index_tools 22 | userguides/index_storm_ref 23 | userguides/index_storm_adv 24 | userguides/index_model_updates 25 | 26 | Many of the concepts above are closely related and this outline represents a reasonable effort to 27 | introduce concepts in a logical order. However, it is difficult to fully understand the potential of 28 | Synapse without grasping the power of the Storm query language to understand, manipulate, and annotate 29 | data. Similarly, it’s hard to understand the effectiveness of Storm without knowledge of the underlying 30 | data model. The outline above is our suggested order but readers are encouraged to skip around or 31 | revisit earlier sections after digesting later sections to better see how these topics are tied 32 | together. 33 | 34 | .. _Index: ../index.html 35 | -------------------------------------------------------------------------------- /docs/synapse/userguides/index_model_updates.rst: -------------------------------------------------------------------------------- 1 | .. _userguide_model_updates: 2 | 3 | Model Updates 4 | ############# 5 | 6 | The following are model updates which have been made with different Synapse releases. 7 | 8 | 9 | .. toctree:: 10 | :titlesonly: 11 | :reversed: 12 | :glob: 13 | 14 | model_updates/update_* -------------------------------------------------------------------------------- /docs/synapse/userguides/index_storm_adv.rst: -------------------------------------------------------------------------------- 1 | .. _userguide_storm_adv: 2 | 3 | Storm Advanced 4 | ############## 5 | 6 | The are several more advanced Storm language language concepts which are documented in the following sections. 7 | 8 | .. toctree:: 9 | :titlesonly: 10 | 11 | storm_adv_vars 12 | storm_adv_methods 13 | storm_adv_control 14 | storm_adv_functions 15 | -------------------------------------------------------------------------------- /docs/synapse/userguides/index_storm_ref.rst: -------------------------------------------------------------------------------- 1 | 2 | .. _userguide_storm_ref: 3 | 4 | Storm Reference 5 | ############### 6 | 7 | Synapse uses the Storm Query language to do lifting and modification of data in the graph. Basic Storm usage is 8 | documented in the following sections. 9 | 10 | .. toctree:: 11 | :titlesonly: 12 | 13 | storm_ref_intro 14 | storm_ref_syntax 15 | storm_ref_lift 16 | storm_ref_filter 17 | storm_ref_pivot 18 | storm_ref_data_mod 19 | storm_ref_subquery 20 | storm_ref_model_introspect 21 | storm_ref_type_specific 22 | storm_ref_cmd 23 | storm_ref_automation 24 | -------------------------------------------------------------------------------- /docs/synapse/userguides/index_tools.rst: -------------------------------------------------------------------------------- 1 | 2 | .. _userguide_tools: 3 | 4 | Tools 5 | ##### 6 | 7 | .. toctree:: 8 | :titlesonly: 9 | 10 | syn_tools_storm 11 | syn_tools_pushfile 12 | syn_tools_pullfile 13 | syn_tools_feed 14 | syn_tools_csvtool 15 | syn_tools_genpkg 16 | syn_tools_easycert 17 | -------------------------------------------------------------------------------- /docs/synapse/userguides/model_updates/update_v2_134_0.rst: -------------------------------------------------------------------------------- 1 | .. _userguide_model_v2_134_0: 2 | 3 | ###################### 4 | v2.134.0 Model Updates 5 | ###################### 6 | 7 | The following model updates were made during the ``v2.134.0`` Synapse release. 8 | 9 | **Light Edges** 10 | 11 | ``addresses`` 12 | When used with a ``risk:mitigation`` and a ``ou:technique`` node, the 13 | edge indicates the mitigation addresses the technique. 14 | -------------------------------------------------------------------------------- /docs/synapse/userguides/model_updates/update_v2_140_0.rst: -------------------------------------------------------------------------------- 1 | .. _userguide_model_v2_140_0: 2 | 3 | ###################### 4 | v2.140.0 Model Updates 5 | ###################### 6 | 7 | The following model updates were made during the ``v2.140.0`` Synapse release. 8 | 9 | ********* 10 | New Types 11 | ********* 12 | 13 | ``file:archive:entry`` 14 | Add a type to capture an archive entry representing a file and metadata 15 | from within a parent archive file. 16 | 17 | ************* 18 | Updated Types 19 | ************* 20 | 21 | ``time`` 22 | Time values with precision beyond milliseconds are now truncated to 23 | millsecond values. 24 | 25 | ``hex`` 26 | Hex types now have whitespace and colon ( ``:`` ) characters stripped 27 | from them when lifting and normalizing them. 28 | 29 | ``inet:ipv6`` 30 | Add comparators for ``>=``, ``>``, ``<=``, ``<`` operations when lifting 31 | and filtering IPV6 values. 32 | 33 | ``ou:naics`` 34 | Update the type to allow recording NIACS sector and subsector prefixes. 35 | -------------------------------------------------------------------------------- /docs/synapse/userguides/model_updates/update_v2_141_0.rst: -------------------------------------------------------------------------------- 1 | 2 | .. _userguide_model_v2_141_0: 3 | 4 | ###################### 5 | v2.141.0 Model Updates 6 | ###################### 7 | 8 | The following model updates were made during the ``v2.141.0`` Synapse release. 9 | 10 | ************** 11 | New Properties 12 | ************** 13 | 14 | ``it:host`` 15 | The form had the following properties added to it: 16 | 17 | ``keyboard:language`` 18 | The primary keyboard input language configured on the host. 19 | 20 | ``keyboard:layout`` 21 | The primary keyboard layout configured on the host. 22 | 23 | ``lang:language`` 24 | The form had the following property added to it: 25 | 26 | ``code`` 27 | The language code for this language. 28 | -------------------------------------------------------------------------------- /docs/synapse/userguides/model_updates/update_v2_142_0.rst: -------------------------------------------------------------------------------- 1 | 2 | .. _userguide_model_v2_142_0: 3 | 4 | ###################### 5 | v2.142.0 Model Updates 6 | ###################### 7 | 8 | The following model updates were made during the ``v2.142.0`` Synapse release. 9 | 10 | ********* 11 | New Forms 12 | ********* 13 | 14 | ``risk:vulnname`` 15 | Add a form to capture vulnerability name such as log4j or rowhammer. 16 | 17 | ************** 18 | New Properties 19 | ************** 20 | 21 | ``it:sec:c2:config`` 22 | The form had the following properties added to it: 23 | 24 | ``decoys`` 25 | An array of URLs used as decoy connections to obfuscate the C2 servers. 26 | 27 | ``ou:technique`` 28 | The form had the following properties added to it: 29 | 30 | ``reporter`` 31 | The organization reporting on the technique. 32 | 33 | ``reporter:name`` 34 | The name of the organization reporting on the technique. 35 | 36 | ``risk:vuln`` 37 | The form had the following properties added to it: 38 | 39 | ``names`` 40 | An array of alternate names for the vulnerability. 41 | 42 | ************* 43 | Updated Types 44 | ************* 45 | 46 | ``hex`` 47 | The ``hex`` base type now accepts a ``zeropad`` option that can be used 48 | to zero-extend a hex string during normalization. 49 | 50 | ``cvss:v2`` 51 | The type now accepts and normalizes unordered CVSS vectors. 52 | 53 | ``cvss:v3`` 54 | The type now accepts and normalizes unordered CVSS vectors. 55 | -------------------------------------------------------------------------------- /docs/synapse/userguides/model_updates/update_v2_143_0.rst: -------------------------------------------------------------------------------- 1 | 2 | .. _userguide_model_v2_143_0: 3 | 4 | ###################### 5 | v2.143.0 Model Updates 6 | ###################### 7 | 8 | The following model updates were made during the ``v2.143.0`` Synapse release. 9 | 10 | ************* 11 | Updated Types 12 | ************* 13 | 14 | ``hex`` 15 | The ``zeropad`` option has been changed from a ``bool`` to an ``int``. 16 | It may now be used to specify the zero extended length of the hex string. 17 | 18 | ****************** 19 | Updated Properties 20 | ****************** 21 | 22 | ``crypto:x509:cert`` 23 | The form had the following properties updated on it: 24 | 25 | ``serial`` 26 | The ``size`` value has been changed to ``zeropad`` to zeropad values 27 | with less than 40 octets, and to allow storing large serial numbers from 28 | malformed certificates. 29 | -------------------------------------------------------------------------------- /docs/synapse/userguides/model_updates/update_v2_144_0.rst: -------------------------------------------------------------------------------- 1 | 2 | .. _userguide_model_v2_144_0: 3 | 4 | ###################### 5 | v2.144.0 Model Updates 6 | ###################### 7 | 8 | The following model updates were made during the ``v2.144.0`` Synapse release. 9 | 10 | ********* 11 | New Forms 12 | ********* 13 | 14 | ``it:dev:repo:type:taxonomy`` 15 | A version control system type taxonomy. 16 | 17 | ``it:dev:repo`` 18 | A version control system instance. 19 | 20 | ``it:dev:repo:remote`` 21 | A remote repo that is tracked for changes/branches/etc. 22 | 23 | ``it:dev:repo:branch`` 24 | A branch in a version control system instance. 25 | 26 | ``it:dev:repo:commit`` 27 | A commit to a repository. 28 | 29 | ``it:dev:repo:diff`` 30 | A diff of a file being applied in a single commit. 31 | 32 | ``it:dev:repo:issue`` 33 | An issue raised in a repository. 34 | 35 | ``it:dev:repo:issue:comment`` 36 | A comment on an issue in a repository. 37 | 38 | ``it:dev:repo:diff:comment`` 39 | A comment on a diff in a repository. 40 | 41 | ************** 42 | New Properties 43 | ************** 44 | 45 | ``inet:dns:answer`` 46 | The form had the following properties added to it: 47 | 48 | ``time`` 49 | The time that the DNS response was transmitted. 50 | -------------------------------------------------------------------------------- /docs/synapse/userguides/model_updates/update_v2_149_0.rst: -------------------------------------------------------------------------------- 1 | 2 | .. _userguide_model_v2_149_0: 3 | 4 | ###################### 5 | v2.149.0 Model Updates 6 | ###################### 7 | 8 | The following model updates were made during the ``v2.149.0`` Synapse release. 9 | 10 | ************** 11 | New Properties 12 | ************** 13 | 14 | ``taxonomy`` 15 | The interface had the following property added to it: 16 | 17 | ``description`` 18 | A definition of the taxonomy entry. 19 | 20 | ``inet:email:message`` 21 | The form had the following property added to it: 22 | 23 | ``cc`` 24 | Email addresses parsed from the "cc" header. 25 | 26 | ``meta:source`` 27 | The form had the following property added to it: 28 | 29 | ``url`` 30 | A URL which documents the meta source. 31 | 32 | ``ou:campaign`` 33 | The form had the following property added to it: 34 | 35 | ``timeline`` 36 | A timeline of significant events related to the campaign. 37 | 38 | ********************* 39 | Deprecated Properties 40 | ********************* 41 | 42 | ``taxonomy`` 43 | The ``taxonomy`` interface had the following property marked as deprecated: 44 | 45 | ``summary`` 46 | -------------------------------------------------------------------------------- /docs/synapse/userguides/model_updates/update_v2_150_0.rst: -------------------------------------------------------------------------------- 1 | 2 | .. _userguide_model_v2_150_0: 3 | 4 | ###################### 5 | v2.150.0 Model Updates 6 | ###################### 7 | 8 | The following model updates were made during the ``v2.150.0`` Synapse release. 9 | 10 | ************* 11 | Updated Types 12 | ************* 13 | 14 | ``inet:url`` 15 | The ``inet:url`` type now recognizes UNC network paths and converts 16 | them into ``smb://`` URLs. 17 | -------------------------------------------------------------------------------- /docs/synapse/userguides/model_updates/update_v2_151_0.rst: -------------------------------------------------------------------------------- 1 | 2 | .. _userguide_model_v2_151_0: 3 | 4 | ###################### 5 | v2.151.0 Model Updates 6 | ###################### 7 | 8 | The following model updates were made during the ``v2.151.0`` Synapse release. 9 | 10 | ********* 11 | New Forms 12 | ********* 13 | 14 | ``it:mitre:attack:flow`` 15 | A MITRE ATT&CK Flow diagram. 16 | -------------------------------------------------------------------------------- /docs/synapse/userguides/model_updates/update_v2_153_0.rst: -------------------------------------------------------------------------------- 1 | 2 | .. _userguide_model_v2_153_0: 3 | 4 | ###################### 5 | v2.153.0 Model Updates 6 | ###################### 7 | 8 | The following model updates were made during the ``v2.153.0`` Synapse release. 9 | 10 | ********************* 11 | Deprecated Properties 12 | ********************* 13 | 14 | ``inet:web:acct`` 15 | The ``inet:web:acct`` form had the following properties marked as deprecated: 16 | 17 | * ``name:en`` 18 | * ``realname:en`` 19 | 20 | ``inet:web:group`` 21 | The ``inet:web:group`` form had the following property marked as deprecated: 22 | 23 | * ``name:en`` 24 | 25 | ``ou:industry`` 26 | The ``ou:industry`` form had the following property marked as deprecated: 27 | 28 | * ``subs`` 29 | -------------------------------------------------------------------------------- /docs/synapse/userguides/model_updates/update_v2_156_0.rst: -------------------------------------------------------------------------------- 1 | 2 | .. _userguide_model_v2_156_0: 3 | 4 | ###################### 5 | v2.156.0 Model Updates 6 | ###################### 7 | 8 | The following model updates were made during the ``v2.156.0`` Synapse release. 9 | 10 | ************** 11 | New Properties 12 | ************** 13 | 14 | ``it:av:scan:result`` 15 | The form had the following properties added to it: 16 | 17 | ``target:ipv4`` 18 | The IPv4 address that was scanned to produce the result. 19 | 20 | ``target:ipv6`` 21 | The IPv6 address that was scanned to produce the result. 22 | 23 | ``ou:campaign`` 24 | The form had the following property added to it: 25 | 26 | ``mitre:attack:campaign`` 27 | A mapping to a Mitre ATT&CK campaign if applicable. 28 | 29 | ``risk:vuln`` 30 | The form had the following property added to it: 31 | 32 | ``id`` 33 | An identifier for the vulnerability. 34 | 35 | ********* 36 | New Forms 37 | ********* 38 | 39 | ``it:mitre:attack:campaign`` 40 | A Mitre ATT&CK Campaign ID. 41 | 42 | ``risk:technique:masquerade`` 43 | Represents the assessment that a node is designed to resemble another 44 | in order to mislead. 45 | 46 | ************* 47 | Updated Types 48 | ************* 49 | 50 | ``it:os:windows:sid`` 51 | The regular expression used to validate the SID has been updated 52 | to allow modeling well-known SID values. 53 | -------------------------------------------------------------------------------- /docs/synapse/userguides/model_updates/update_v2_167_0.rst: -------------------------------------------------------------------------------- 1 | 2 | 3 | .. _userguide_model_v2_167_0: 4 | 5 | ###################### 6 | v2.167.0 Model Updates 7 | ###################### 8 | 9 | The following model updates were made during the ``v2.167.0`` Synapse release. 10 | 11 | ************* 12 | Updated Types 13 | ************* 14 | 15 | ``file:path`` 16 | Normalizing paths such as ``../.././..`` previously failed. This now 17 | produces an empty path. 18 | 19 | **************** 20 | Deprecated Types 21 | **************** 22 | 23 | The following types have been marked as deprecated: 24 | 25 | * ``edge`` 26 | * ``timeedge`` 27 | 28 | **************** 29 | Deprecated Forms 30 | **************** 31 | 32 | The following forms have been marked as deprecated: 33 | 34 | * ``graph:cluster`` 35 | * ``graph:node`` 36 | * ``graph:event`` 37 | * ``edge:refs`` 38 | * ``edge:has`` 39 | * ``edge:wentto`` 40 | * ``graph:edge`` 41 | * ``graph:timeedge`` 42 | -------------------------------------------------------------------------------- /docs/synapse/userguides/model_updates/update_v2_168_0.rst: -------------------------------------------------------------------------------- 1 | 2 | .. _userguide_model_v2_168_0: 3 | 4 | ###################### 5 | v2.168.0 Model Updates 6 | ###################### 7 | 8 | The following model updates were made during the ``v2.168.0`` Synapse release. 9 | 10 | ********* 11 | New Forms 12 | ********* 13 | 14 | ``plan:system`` 15 | A planning or behavioral analysis system that defines phases and 16 | procedures. 17 | 18 | ``plan:phase`` 19 | A phase within a planning system which may be used to group steps 20 | within a procedure. 21 | 22 | ``plan:procedure`` 23 | A procedure consisting of steps. 24 | 25 | ``plan:procedure:type:taxonomy`` 26 | A taxonomy of procedure types. 27 | 28 | ``plan:procedure:variable`` 29 | A variable used by a procedure. 30 | 31 | ``plan:procedure:step`` 32 | A step within a procedure. 33 | 34 | ``plan:procedure:link`` 35 | A link between steps in a procedure. 36 | -------------------------------------------------------------------------------- /docs/synapse/userguides/model_updates/update_v2_170_0.rst: -------------------------------------------------------------------------------- 1 | 2 | .. _userguide_model_v2_170_0: 3 | 4 | ###################### 5 | v2.170.0 Model Updates 6 | ###################### 7 | 8 | The following model updates were made during the ``v2.170.0`` Synapse release. 9 | 10 | 11 | ********* 12 | New Forms 13 | ********* 14 | 15 | ``file:mime:lnk`` 16 | Metadata pulled from a Windows shortcut or LNK file. 17 | 18 | ``it:mitre:attack:datasource`` 19 | A MITRE ATT&CK Datasource ID. 20 | 21 | ``it:mitre:attack:data:component`` 22 | A MITRE ATT&CK data component. 23 | 24 | ************** 25 | New Properties 26 | ************** 27 | 28 | ``it:mitre:attack:technique`` 29 | The form had the following property added to it: 30 | 31 | ``data:components`` 32 | An array of MITRE ATT&CK data components that detect the ATT&CK technique. 33 | 34 | ``it:prod:hardware`` 35 | The form had the following properties added to it: 36 | 37 | ``manufacturer`` 38 | The organization that manufactures this hardware. 39 | 40 | ``manufacturer:name`` 41 | The name of the organization that manufactures this hardware. 42 | 43 | ********************* 44 | Deprecated Properties 45 | ********************* 46 | 47 | ``it:prod:hardware`` 48 | The ``it:prod:hardware`` form had the following property marked as deprecated: 49 | 50 | * ``make`` 51 | -------------------------------------------------------------------------------- /docs/synapse/userguides/model_updates/update_v2_173_1.rst: -------------------------------------------------------------------------------- 1 | .. _userguide_model_v2_173_1: 2 | 3 | ###################### 4 | v2.173.1 Model Updates 5 | ###################### 6 | 7 | The following model updates were made during the ``v2.173.1`` Synapse release. 8 | 9 | ************** 10 | New Properties 11 | ************** 12 | 13 | ``ou:conference`` 14 | The form had the following property added to it: 15 | 16 | ``names`` 17 | An array of alternate names for the conference. 18 | 19 | ``ps:contact`` 20 | The form had the following property added to it: 21 | 22 | ``titles`` 23 | An array of alternate titles for the contact. 24 | 25 | *********** 26 | Light Edges 27 | *********** 28 | 29 | ``uses`` 30 | When used with a ``plan:procedure:step`` node, the edge indicates the 31 | step in the procedure makes use of the target node. 32 | -------------------------------------------------------------------------------- /docs/synapse/userguides/model_updates/update_v2_176_0.rst: -------------------------------------------------------------------------------- 1 | .. _userguide_model_v2_176_0: 2 | 3 | ###################### 4 | v2.176.0 Model Updates 5 | ###################### 6 | 7 | The following model updates were made during the ``v2.176.0`` Synapse release. 8 | 9 | ********* 10 | New Forms 11 | ********* 12 | 13 | ``inet:service:thread`` 14 | A message thread. 15 | 16 | ************** 17 | New Properties 18 | ************** 19 | 20 | ``inet:service:message`` 21 | The form had the following properties added to it: 22 | 23 | ``thread`` 24 | The thread which contains the message. 25 | 26 | ``title`` 27 | The message title. 28 | 29 | ************** 30 | Updated Forms 31 | ************** 32 | 33 | ``inet:service:account`` 34 | The form now inherits from the ``inet:service:object`` interface. 35 | -------------------------------------------------------------------------------- /docs/synapse/userguides/model_updates/update_v2_177_0.rst: -------------------------------------------------------------------------------- 1 | 2 | 3 | .. _userguide_model_v2_177_0: 4 | 5 | ###################### 6 | v2.177.0 Model Updates 7 | ###################### 8 | 9 | The following model updates were made during the ``v2.177.0`` Synapse release. 10 | 11 | ********* 12 | New Forms 13 | ********* 14 | 15 | ``inet:service:message:type:taxonomy`` 16 | A message type taxonomy. 17 | 18 | 19 | ``meta:rule:type:taxonomy`` 20 | A taxonomy for meta:rule types. 21 | 22 | 23 | 24 | ************** 25 | New Properties 26 | ************** 27 | 28 | ``biz:deal`` 29 | The form had the following property added to it: 30 | 31 | ``id`` 32 | An identifier for the deal. 33 | 34 | 35 | ``file:mime:lnk`` 36 | The form had the following properties added to it: 37 | 38 | 39 | ``driveserial`` 40 | The drive serial number of the volume the link target is stored on. 41 | 42 | 43 | ``iconindex`` 44 | A resource index for an icon within an icon location. 45 | 46 | 47 | ``machineid`` 48 | The NetBIOS name of the machine where the link target was last located. 49 | 50 | 51 | ``inet:service:message`` 52 | The form had the following property added to it: 53 | 54 | ``type`` 55 | The type of message. 56 | 57 | 58 | ``meta:rule`` 59 | The form had the following property added to it: 60 | 61 | ``type`` 62 | The rule type. 63 | -------------------------------------------------------------------------------- /docs/synapse/userguides/model_updates/update_v2_186_0.rst: -------------------------------------------------------------------------------- 1 | 2 | 3 | .. _userguide_model_v2_186_0: 4 | 5 | ###################### 6 | v2.186.0 Model Updates 7 | ###################### 8 | 9 | The following model updates were made during the ``v2.186.0`` Synapse release. 10 | 11 | ************** 12 | New Properties 13 | ************** 14 | 15 | ``risk:tool:software`` 16 | The form had the following property added to it: 17 | 18 | ``id`` 19 | An ID for the tool. 20 | 21 | -------------------------------------------------------------------------------- /docs/synapse/userguides/model_updates/update_v2_187_0.rst: -------------------------------------------------------------------------------- 1 | 2 | 3 | .. _userguide_model_v2_187_0: 4 | 5 | ###################### 6 | v2.187.0 Model Updates 7 | ###################### 8 | 9 | The following model updates were made during the ``v2.187.0`` Synapse release. 10 | 11 | ************* 12 | Updated Types 13 | ************* 14 | 15 | ``it:sec:cpe`` 16 | Update the parsing of CPE 2.2 and CPE 2.3 strings to be strict according 17 | to the CPE specification (NISTIR 7695). 18 | -------------------------------------------------------------------------------- /docs/synapse/userguides/model_updates/update_v2_189_0.rst: -------------------------------------------------------------------------------- 1 | 2 | 3 | .. _userguide_model_v2_189_0: 4 | 5 | ###################### 6 | v2.189.0 Model Updates 7 | ###################### 8 | 9 | The following model updates were made during the ``v2.189.0`` Synapse release. 10 | 11 | ************** 12 | New Properties 13 | ************** 14 | 15 | ``risk:vulnerable`` 16 | The form had the following property added to it: 17 | 18 | ``technique`` 19 | The technique that the node is susceptible to. 20 | 21 | -------------------------------------------------------------------------------- /docs/synapse/userguides/model_updates/update_v2_197_0.rst: -------------------------------------------------------------------------------- 1 | 2 | 3 | .. _userguide_model_v2_197_0: 4 | 5 | ###################### 6 | v2.197.0 Model Updates 7 | ###################### 8 | 9 | The following model updates were made during the ``v2.197.0`` Synapse release. 10 | 11 | ********* 12 | New Forms 13 | ********* 14 | 15 | ``doc:requirement`` 16 | A single requirement, often defined by a standard. 17 | 18 | 19 | ``doc:resume`` 20 | A CV/resume document. 21 | 22 | 23 | ``doc:resume:type:taxonomy`` 24 | A taxonomy of resume types. 25 | 26 | 27 | ``doc:requirement:type:taxonomy`` 28 | A taxonomy of requirement types. 29 | 30 | 31 | 32 | ****************** 33 | Updated Properties 34 | ****************** 35 | 36 | ``ou:enacted`` 37 | The form had the following property updated: 38 | 39 | 40 | The property ``doc`` has been modified to allow the ``doc:requirement`` form. 41 | 42 | 43 | **************** 44 | Deprecated Types 45 | **************** 46 | 47 | The following types have been marked as deprecated: 48 | 49 | 50 | * ``ou:alias`` 51 | 52 | 53 | 54 | ********************* 55 | Deprecated Properties 56 | ********************* 57 | 58 | ``ou:org`` 59 | The form had the following property deprecated: 60 | 61 | ``alias`` 62 | Deprecated. Please use ``ou:org:names``. 63 | 64 | -------------------------------------------------------------------------------- /docs/synapse/userguides/model_updates/update_v2_198_0.rst: -------------------------------------------------------------------------------- 1 | 2 | 3 | .. _userguide_model_v2_198_0: 4 | 5 | ###################### 6 | v2.198.0 Model Updates 7 | ###################### 8 | 9 | The following model updates were made during the ``v2.198.0`` Synapse release. 10 | 11 | ************** 12 | New Properties 13 | ************** 14 | 15 | ``it:exec:query`` 16 | The form had the following properties added to it: 17 | 18 | 19 | ``service:account`` 20 | The service account which ran the query. 21 | 22 | 23 | ``service:instance`` 24 | The service instance which was queried. 25 | 26 | 27 | ``service:platform`` 28 | The service platform which was queried. 29 | 30 | 31 | ``it:log:event`` 32 | The form had the following properties added to it: 33 | 34 | 35 | ``service:account`` 36 | The service account which generated the log event. 37 | 38 | 39 | ``service:instance`` 40 | The service instance which generated the log event. 41 | 42 | 43 | ``service:platform`` 44 | The service platform which generated the log event. 45 | 46 | 47 | ``risk:alert`` 48 | The form had the following properties added to it: 49 | 50 | 51 | ``service:account`` 52 | The service account which generated the alert. 53 | 54 | 55 | ``service:instance`` 56 | The service instance which generated the alert. 57 | 58 | 59 | ``service:platform`` 60 | The service platform which generated the alert. 61 | 62 | -------------------------------------------------------------------------------- /docs/synapse/userguides/model_updates/update_v2_201_0.rst: -------------------------------------------------------------------------------- 1 | 2 | 3 | .. _userguide_model_v2_201_0: 4 | 5 | ###################### 6 | v2.201.0 Model Updates 7 | ###################### 8 | 9 | The following model updates were made during the ``v2.201.0`` Synapse release. 10 | 11 | ************** 12 | New Properties 13 | ************** 14 | 15 | ``risk:mitigation:type:taxonomy`` 16 | The form had the following properties added to it: 17 | 18 | 19 | ``base`` 20 | The base taxon. 21 | 22 | 23 | ``depth`` 24 | The depth indexed from 0. 25 | 26 | 27 | ``desc`` 28 | A definition of the taxonomy entry. 29 | 30 | 31 | ``parent`` 32 | The taxonomy parent. 33 | 34 | 35 | ``sort`` 36 | A display sort order for siblings. 37 | 38 | 39 | ``summary`` 40 | Deprecated. Please use title/desc. 41 | 42 | 43 | ``title`` 44 | A brief title of the definition. 45 | 46 | 47 | 48 | ************* 49 | Updated Types 50 | ************* 51 | 52 | ``risk:mitigation:type:taxonomy`` 53 | The type interface has been modified to inherit from the ``meta:taxonomy`` interface. 54 | 55 | 56 | 57 | ****************** 58 | Updated Properties 59 | ****************** 60 | 61 | ``proj:ticket`` 62 | The form had the following property updated: 63 | 64 | 65 | The property ``type`` had an example added to its definition. 66 | 67 | -------------------------------------------------------------------------------- /docs/synapse/userguides/model_updates/update_v2_203_0.rst: -------------------------------------------------------------------------------- 1 | 2 | 3 | .. _userguide_model_v2_203_0: 4 | 5 | ###################### 6 | v2.203.0 Model Updates 7 | ###################### 8 | 9 | The following model updates were made during the ``v2.203.0`` Synapse release. 10 | 11 | ********* 12 | New Forms 13 | ********* 14 | 15 | ``meta:feed:type:taxonomy`` 16 | A data feed type taxonomy. 17 | 18 | 19 | ``meta:feed`` 20 | A data feed provided by a specific source. 21 | 22 | 23 | 24 | *********** 25 | Light Edges 26 | *********** 27 | 28 | ``found`` 29 | When used with a ``meta:feed`` node, the edge indicates the meta:feed 30 | produced the target node. 31 | 32 | 33 | 34 | **************** 35 | Deprecated Types 36 | **************** 37 | 38 | The following forms have been marked as deprecated: 39 | 40 | 41 | * ``meta:seen`` 42 | 43 | -------------------------------------------------------------------------------- /docs/synapse/userguides/model_updates/update_v2_204_0.rst: -------------------------------------------------------------------------------- 1 | 2 | 3 | .. _userguide_model_v2_204_0: 4 | 5 | ###################### 6 | v2.204.0 Model Updates 7 | ###################### 8 | 9 | The following model updates were made during the ``v2.204.0`` Synapse release. 10 | 11 | ************** 12 | New Properties 13 | ************** 14 | 15 | ``ps:contact`` 16 | The form had the following property added to it: 17 | 18 | ``id`` 19 | A type or source specific unique ID for the contact. 20 | 21 | -------------------------------------------------------------------------------- /docs/synapse/userguides/model_updates/update_v2_206_0.rst: -------------------------------------------------------------------------------- 1 | 2 | 3 | .. _userguide_model_v2_206_0: 4 | 5 | ###################### 6 | v2.206.0 Model Updates 7 | ###################### 8 | 9 | The following model updates were made during the ``v2.206.0`` Synapse release. 10 | 11 | ********* 12 | New Forms 13 | ********* 14 | 15 | ``tel:mob:tadig`` 16 | A Transferred Account Data Interchange Group number issued to a GSM carrier. 17 | 18 | 19 | 20 | ************** 21 | New Properties 22 | ************** 23 | 24 | ``it:network`` 25 | The form had the following property added to it: 26 | 27 | ``dns:resolvers`` 28 | An array of DNS servers configured to resolve requests for hosts on the 29 | network. 30 | 31 | 32 | ``tel:mob:carrier`` 33 | The form had the following property added to it: 34 | 35 | ``tadig`` 36 | The TADIG code issued to the carrier. 37 | 38 | 39 | 40 | *********** 41 | Light Edges 42 | *********** 43 | 44 | ``has`` 45 | When used with a ``meta:ruleset`` and an ``it:app:yara:rule`` node, the 46 | edge indicates the meta:ruleset includes the it:app:yara:rule. 47 | 48 | 49 | ``has`` 50 | When used with a ``meta:ruleset`` and an ``it:app:snort:rule`` node, the 51 | edge indicates the meta:ruleset includes the it:app:snort:rule. 52 | 53 | 54 | ``has`` 55 | When used with a ``meta:ruleset`` and an ``inet:service:rule`` node, the 56 | edge indicates the meta:ruleset includes the inet:service:rule. 57 | 58 | -------------------------------------------------------------------------------- /docs/synapse/userguides/model_updates/update_v2_212_0.rst: -------------------------------------------------------------------------------- 1 | 2 | 3 | .. _userguide_model_v2_212_0: 4 | 5 | ###################### 6 | v2.212.0 Model Updates 7 | ###################### 8 | 9 | The following model updates were made during the ``v2.212.0`` Synapse release. 10 | 11 | ********* 12 | New Forms 13 | ********* 14 | 15 | ``inet:tls:ja4:sample`` 16 | A JA4 TLS client fingerprint used by a client. 17 | 18 | 19 | ``inet:tls:ja4s:sample`` 20 | A JA4S TLS server fingerprint used by a server. 21 | 22 | 23 | ``inet:tls:ja4`` 24 | A JA4 TLS client fingerprint. 25 | 26 | 27 | ``inet:tls:ja4s`` 28 | A JA4S TLS server fingerprint. 29 | 30 | 31 | 32 | ************** 33 | New Properties 34 | ************** 35 | 36 | ``inet:tls:handshake`` 37 | The form had the following properties added to it: 38 | 39 | 40 | ``client:ja3`` 41 | The JA3 fingerprint of the client request. 42 | 43 | 44 | ``client:ja4`` 45 | The JA4 fingerprint of the client request. 46 | 47 | 48 | ``server:ja3s`` 49 | The JA3S fingerprint of the server response. 50 | 51 | 52 | ``server:ja4s`` 53 | The JA4S fingerprint of the server response. 54 | 55 | 56 | 57 | ********************* 58 | Deprecated Properties 59 | ********************* 60 | 61 | ``inet:tls:handshake`` 62 | The form had the following properties deprecated: 63 | 64 | 65 | ``client:fingerprint:ja3`` 66 | Deprecated. Please use ``:client:ja3``. 67 | 68 | 69 | ``server:fingerprint:ja3`` 70 | Deprecated. Please use ``:server:ja3s``. 71 | 72 | -------------------------------------------------------------------------------- /docs/synapse/userguides/syn_tools_genpkg.rst: -------------------------------------------------------------------------------- 1 | .. highlight:: none 2 | 3 | .. _syn-tools-genpkg: 4 | 5 | genpkg 6 | ====== 7 | 8 | The Synapse ``genpkg`` tool can be used to generate a Storm :ref:`gloss-package` containing new Storm commands 9 | and Storm modules from a YAML definition and optionally push it to a Cortex or PkgRepo. 10 | 11 | For additional details on using the ``genpkg`` tool see :ref:`dev-rapid-power-ups-build` a Rapid Power-Up. 12 | -------------------------------------------------------------------------------- /examples/power-ups/rapid/acme-hello/storm/commands/acme.hello.mayyield.storm: -------------------------------------------------------------------------------- 1 | function nodeGenrFunc(fqdn) { 2 | // Fake a DNS lookup and make a few inet:dns:a records... 3 | [ inet:dns:a=($fqdn, 1.2.3.4) ] 4 | [ inet:dns:a=($fqdn, 123.123.123.123) ] 5 | } 6 | 7 | divert $cmdopts.yield $nodeGenrFunc($node) 8 | -------------------------------------------------------------------------------- /examples/power-ups/rapid/acme-hello/storm/commands/acme.hello.omgopts.storm: -------------------------------------------------------------------------------- 1 | // An init {} block only runs once even if there are multiple nodes in the pipeline. 2 | 3 | init { 4 | 5 | // Set global debug (once) if the user specified --debug 6 | if $cmdopts.debug { $lib.debug = $lib.true } 7 | 8 | if ($cmdopts.hehe) { $lib.print("User Specified hehe: {hehe}", hehe=$cmdopts.hehe) } 9 | 10 | // Normalize the FQDN in case we want to send it to an external system 11 | ($ok, $fqdn) = $lib.trycast(inet:fqdn, $cmdopts.fqdn) 12 | if (not $ok) { 13 | $lib.exit("Invalid FQDN Specified: {fqdn}", fqdn=$cmdopts.fqdn) 14 | } 15 | 16 | // Maybe call an API here or something... 17 | $lib.print("FQDN: {fqdn}", fqdn=$fqdn) 18 | } 19 | 20 | 21 | // You may also act on nodes in the pipeline 22 | $lib.print("GOT NODE: {repr}", repr=$node.repr()) 23 | 24 | if $lib.debug { $lib.print("debug mode detected!") } 25 | 26 | // Any nodes still in the pipeline are sent as output 27 | -------------------------------------------------------------------------------- /examples/power-ups/rapid/acme-hello/storm/commands/acme.hello.sayhi.storm: -------------------------------------------------------------------------------- 1 | $hello = $lib.import(acme.hello) 2 | $hello.woot("hello storm!") 3 | -------------------------------------------------------------------------------- /examples/power-ups/rapid/acme-hello/storm/modules/acme.hello.privsep.storm: -------------------------------------------------------------------------------- 1 | function getFooByBar(bar) { 2 | 3 | // Retrieve an API key from protected storage 4 | $apikey = $lib.globals.get(acme:hello:apikey) 5 | 6 | $headers = ({ 7 | "apikey": $apikey 8 | }) 9 | 10 | $url = `https://acme.newp/api/v1/foo/{$bar}` 11 | 12 | // Use the API key on the callers behalf 13 | $resp = $lib.inet.http.get($url, headers=$headers) 14 | if ($resp.code != 200) { 15 | $lib.warn("/api/v1/foo returned HTTP code: {code}", code=$resp.code) 16 | return($lib.null) 17 | } 18 | 19 | // Return the JSON response (but not the API key) 20 | return($resp.json()) 21 | } 22 | -------------------------------------------------------------------------------- /examples/power-ups/rapid/acme-hello/storm/modules/acme.hello.storm: -------------------------------------------------------------------------------- 1 | function woot(text) { 2 | $lib.print($text) 3 | return($lib.null) 4 | } 5 | -------------------------------------------------------------------------------- /examples/power-ups/rapid/acme-hello/test_acme_hello.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | import synapse.tests.utils as s_test 4 | 5 | dirname = os.path.abspath(os.path.dirname(__file__)) 6 | 7 | class AcmeHelloTest(s_test.StormPkgTest): 8 | 9 | assetdir = os.path.join(dirname, 'testassets') 10 | pkgprotos = (os.path.join(dirname, 'acme-hello.yaml'),) 11 | 12 | async def test_acme_hello(self): 13 | 14 | async with self.getTestCore() as core: 15 | 16 | msgs = await core.stormlist('acme.hello.sayhi') 17 | self.stormIsInPrint('hello storm!', msgs) 18 | self.stormHasNoWarnErr(msgs) 19 | 20 | async def test_acme_hello_mayyield(self): 21 | 22 | async with self.getTestCore() as core: 23 | 24 | msgs = await core.stormlist('[ inet:fqdn=vertex.link ] | acme.hello.mayyield') 25 | self.stormHasNoWarnErr(msgs) 26 | nodes = [m[1] for m in msgs if m[0] == 'node'] 27 | self.len(1, nodes) 28 | self.eq(('inet:fqdn', 'vertex.link'), nodes[0][0]) 29 | 30 | msgs = await core.stormlist('[ inet:fqdn=vertex.link ] | acme.hello.mayyield --yield') 31 | self.stormHasNoWarnErr(msgs) 32 | nodes = [m[1] for m in msgs if m[0] == 'node'] 33 | self.len(2, nodes) 34 | self.eq(('inet:dns:a', ('vertex.link', 0x01020304)), nodes[0][0]) 35 | self.eq(('inet:dns:a', ('vertex.link', 0x7b7b7b7b)), nodes[1][0]) 36 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | pyOpenSSL>=24.0.0,<24.3.0 2 | msgpack>=1.0.5,<1.2.0 3 | xxhash>=1.4.4,<3.6.0 4 | lmdb>=1.2.1,<1.7.0 5 | tornado>=6.2.0,<7.0.0 6 | regex>=2022.9.11 7 | PyYAML>=5.4,<6.1.0 8 | aiohttp>=3.10.0,<4.0 9 | aiohttp-socks>=0.9.0,<0.11.0 10 | aioimaplib>=1.1.0,<1.2.0 11 | aiosmtplib>=3.0.0,<3.1.0 12 | prompt_toolkit>=3.0.29,<3.1.0 13 | lark==1.2.2 14 | Pygments>=2.7.4,<2.20.0 15 | fastjsonschema>=2.20.0,<2.22.0 16 | packaging>=20.0,<25.0 17 | stix2-validator>=3.2.0,<4.0.0 18 | vcrpy>=4.3.1,<5.2.0 19 | base58>=2.1.0,<2.2.0 20 | python-bitcoinlib>=0.11.0,<0.13.0 21 | pycryptodome>=3.11.0,<3.23.0 22 | typing-extensions>=3.7.4,<5.0.0 # synapse.vendor.xrpl req 23 | scalecodec>=1.0.2,<1.3.0 # synapse.vendor.substrateinterface req 24 | cbor2>=5.4.1,<5.7.0 25 | bech32==1.2.0 26 | oauthlib>=3.2.1,<4.0.0 27 | idna>=3.6,<3.11 28 | python-dateutil>=2.8,<3.0 29 | pytz>=2023.3,<2025.3 30 | beautifulsoup4[html5lib]>=4.11.1,<5.0.0 31 | # Cryptography is a pyopenssl dependency which has now has a maximum version 32 | # pin. Cryptography also vendors a copy of OpenSSL, so it needs to be able to 33 | # have a minimum version bumped in the event of a OpenSSL vulnerability that 34 | # needs to be patched. 35 | cryptography>=43.0.1,<44.0.0 36 | vtx-yyjson>=4.3.0,<5.0.0 37 | -------------------------------------------------------------------------------- /requirements_dev.txt: -------------------------------------------------------------------------------- 1 | -r requirements.txt 2 | pytest>=7.2.0,<8.0.0 3 | autopep8>=2.0.4,<3.0.0 4 | pytest-cov>=4.0.0,<5.0.0 5 | pycodestyle>=2.10.0,<3.0.0 6 | bump2version>=1.0.1,<1.1.0 7 | pytest-xdist>=3.0.2,<4.0.0 8 | coverage>=7.0.0,<8.0.0 9 | -------------------------------------------------------------------------------- /requirements_doc.txt: -------------------------------------------------------------------------------- 1 | -r requirements_dev.txt 2 | sphinx>=8.0.0,<9.0.0 3 | sphinx-rtd-theme>=3.0.0,<4.0.0 4 | sphinx-notfound-page>=1.0.4,<2.0.0 5 | jinja2>=3.1.4,<4.0.0 6 | -------------------------------------------------------------------------------- /scripts/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/scripts/__init__.py -------------------------------------------------------------------------------- /scripts/pep8_staged_files.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Requires autopep8 to be installed. 4 | # Script for cleaning up most PEP8 related errors checked by the pre-commit hook. 5 | # 6 | import os 7 | import subprocess 8 | import sys 9 | 10 | def system(*args, **kwargs): 11 | kwargs.setdefault('stdout', subprocess.PIPE) 12 | proc = subprocess.Popen(args, **kwargs) 13 | out, err = proc.communicate() 14 | return out 15 | 16 | def main(): 17 | cwd = os.getcwd() 18 | if '.git' not in os.listdir(cwd): 19 | print('Must be run from the root of the repository.') 20 | sys.exit(1) 21 | files = system('git', 'diff', '--cached', '--name-only').decode("utf-8") 22 | files = [file.strip() for file in files.split('\n') if file.strip().endswith('.py')] 23 | 24 | if not files: 25 | sys.exit(0) 26 | 27 | args = ['autopep8', '--in-place'] 28 | 29 | args.extend(files) 30 | output = system(*args, cwd=cwd) 31 | if output: 32 | print(output.decode("utf-8"),) 33 | sys.exit(1) 34 | sys.exit(0) 35 | 36 | 37 | if __name__ == '__main__': 38 | main() 39 | -------------------------------------------------------------------------------- /scripts/replace_commit.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import subprocess 3 | 4 | # Replace the embedded commit information with our current git commit 5 | 6 | def main(): 7 | try: 8 | ret = subprocess.run(['git', 'rev-parse', 'HEAD'], 9 | capture_output=True, 10 | timeout=15, 11 | check=False, 12 | text=True, 13 | ) 14 | except Exception as e: 15 | print(f'Error grabbing commit: {e}') 16 | return 1 17 | else: 18 | commit = ret.stdout.strip() 19 | fp = './synapse/lib/version.py' 20 | with open(fp, 'rb') as fd: 21 | buf = fd.read() 22 | content = buf.decode() 23 | new_content = content.replace("commit = ''", f"commit = '{commit}'") 24 | if content == new_content: 25 | print(f'Unable to insert commit into {fp}') 26 | return 1 27 | with open(fp, 'wb') as fd: 28 | _ = fd.write(new_content.encode()) 29 | print(f'Inserted commit {commit} into {fp}') 30 | return 0 31 | 32 | if __name__ == '__main__': 33 | sys.exit(main()) 34 | -------------------------------------------------------------------------------- /scripts/testrunner.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | # Standalone test runner for synapse tests 5 | # This will run unit tests using pytest and generate HTML coverage reports. 6 | # The use of this script requires the installation of pytest, pytest-cov and 7 | # pytest-xdist python packages, which are not required for other synapse 8 | # developement or deployment. 9 | ############################################################################## 10 | 11 | MODULE=synapse 12 | HTML_DIR=./build/htmlcov 13 | INDEX=$HTML_DIR/index.html 14 | COVREQ=80 15 | 16 | if [ -e $HTML_DIR ]; then 17 | echo "Removing existing coverage reports." 18 | rm -rf $HTML_DIR 19 | fi 20 | 21 | COVFAIL="" 22 | if [ "$*" = '' ]; then 23 | COVFAIL="--cov-fail-under=$COVREQ" 24 | fi 25 | 26 | python -m pytest -v -s --durations 6 -n auto --maxfail 6 -rs $COVFAIL --cov $MODULE --no-cov-on-fail --cov-report=html:$HTML_DIR $* 27 | 28 | if [ $? -eq 0 ]; then 29 | if [ -e $INDEX ]; then 30 | echo "Opening coverage report." 31 | xdg-open $INDEX & 32 | fi 33 | fi -------------------------------------------------------------------------------- /scripts/verify_version.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import tomllib 4 | 5 | # Ensure our CI tag value matches our pyproject.toml value 6 | 7 | def main(argv): 8 | envar = 'CIRCLE_TAG' 9 | if argv: 10 | envar = argv[0] 11 | etag = os.getenv('CIRCLE_TAG', '') 12 | etag = etag.lstrip('v') 13 | 14 | with open('pyproject.toml', 'r') as fd: 15 | data = tomllib.loads(fd.read()) 16 | ptag = data.get('project', {}).get('version', 'project.version missing') 17 | 18 | if etag != ptag: 19 | info = f"Git tag from {envar} => {etag} does not match the version of this app: {ptag}" 20 | print(info) 21 | return 1 22 | return 0 23 | 24 | if __name__ == '__main__': 25 | sys.exit(main(sys.argv[1:])) 26 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [pycodestyle] 2 | format = pylint 3 | max-line-length = 120 4 | select = E111,E101,E114, 5 | E201,E202,E203,E221,E222,E223,E224,E225, 6 | E226,E227,E228,E231,E241,E242,E251, 7 | E265, 8 | E303,E304, 9 | E502, 10 | E711,E712,E713,E714,E721, 11 | E741,E742,E743, 12 | W191, 13 | W291,W293,W292, 14 | W391, 15 | W601,W602,W603,W604,W605,W606, 16 | 17 | [vtx_common:github_release] 18 | release-name = Synapse 19 | extra-lines = For complete changelog entries, see the following https://synapse.docs.vertex.link/en/latest/synapse/changelog.html 20 | mail-dest = releases@mg2.vertex.link 21 | mail-sender = Vertex Releases 22 | mail-domain = mg2.vertex.link 23 | -------------------------------------------------------------------------------- /synapse/__init__.py: -------------------------------------------------------------------------------- 1 | ''' 2 | The synapse intelligence analysis framework. 3 | ''' 4 | 5 | import sys 6 | if (sys.version_info.major, sys.version_info.minor) < (3, 11): # pragma: no cover 7 | raise Exception('synapse is not supported on Python versions < 3.11') 8 | 9 | # checking maximum *signed* integer size to determine the interpreter arch 10 | if sys.maxsize < 9223372036854775807: # pragma: no cover 11 | raise Exception('synapse is only supported on 64 bit architectures') 12 | 13 | # Checking if the interpreter is running with -OO - if so, this breaks 14 | # behavior which relies on __doc__ being set. Warn the user of this 15 | # degraded behavior. Could affect Cli, Cmdr, Cortex, and other components. 16 | if sys.flags.optimize >= 2: 17 | import warnings 18 | mesg = '''Synapse components may experience degraded capabilities with sys.flags.optimize >=2.''' 19 | warnings.warn(mesg, RuntimeWarning) 20 | 21 | import lmdb 22 | if tuple([int(x) for x in lmdb.__version__.split('.')]) < (1, 0, 0): # pragma: no cover 23 | raise Exception('synapse is only supported on version >= 1.0.0 of the lmdb python module') 24 | 25 | from synapse.lib.version import version, verstring 26 | # Friendly __version__ string alias 27 | __version__ = verstring 28 | -------------------------------------------------------------------------------- /synapse/cells.py: -------------------------------------------------------------------------------- 1 | import synapse.axon as s_axon 2 | import synapse.cortex as s_cortex 3 | import synapse.cryotank as s_cryotank 4 | 5 | import synapse.lib.aha as s_aha 6 | import synapse.lib.jsonstor as s_jsonstor 7 | 8 | aha = s_aha.AhaCell 9 | axon = s_axon.Axon 10 | cortex = s_cortex.Cortex 11 | cryotank = s_cryotank.CryoCell 12 | jsonstor = s_jsonstor.JsonStorCell 13 | -------------------------------------------------------------------------------- /synapse/cmds/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/synapse/cmds/__init__.py -------------------------------------------------------------------------------- /synapse/data/__init__.py: -------------------------------------------------------------------------------- 1 | import os 2 | import logging 3 | 4 | import synapse.common as s_common 5 | 6 | import synapse.lib.json as s_json 7 | import synapse.lib.datfile as s_datfile 8 | import synapse.lib.msgpack as s_msgpack 9 | 10 | logger = logging.getLogger(__name__) 11 | 12 | dirname = os.path.dirname(__file__) 13 | 14 | def get(name, defval=None): 15 | ''' 16 | Return an object from the embedded synapse data folder. 17 | 18 | Example: 19 | 20 | for tld in synapse.data.get('iana.tlds'): 21 | dostuff(tld) 22 | 23 | NOTE: Files are named synapse/data/.mpk 24 | ''' 25 | with s_datfile.openDatFile(f'synapse.data/{name}.mpk') as fd: 26 | return s_msgpack.un(fd.read()) 27 | 28 | def getJSON(name): 29 | with s_datfile.openDatFile(f'synapse.data/{name}.json') as fd: 30 | return s_json.load(fd) 31 | 32 | def path(*names): 33 | return s_common.genpath(dirname, *names) 34 | -------------------------------------------------------------------------------- /synapse/data/attack-flow/README.md: -------------------------------------------------------------------------------- 1 | The file `attack-flow-schema-2.0.0.json` in this directory is a heavily modified version of 2 | https://github.com/center-for-threat-informed-defense/attack-flow/blob/main/stix/attack-flow-schema-2.0.0.json. 3 | The open source license for the original is included in this directory as LICENSE.txt. 4 | -------------------------------------------------------------------------------- /synapse/data/certs/crls/The Vertex Project Intermediate CA 00.crl: -------------------------------------------------------------------------------- 1 | -----BEGIN X509 CRL----- 2 | MIICjzB5MA0GCSqGSIb3DQEBCwUAMDAxLjAsBgNVBAMMJVRoZSBWZXJ0ZXggUHJv 3 | amVjdCBJbnRlcm1lZGlhdGUgQ0EgMDAYDzIwMjMwMTA1MTQ1ODAxWjAlMCMCEB2/ 4 | x3W5PXmTqnluQdy12aoYDzIwMjMwMTA1MTQ1ODAxWjANBgkqhkiG9w0BAQsFAAOC 5 | AgEAoe7ykYrHwQNPlIrEpYNKs7NA1/MfYxaJEntryL34op/ZNcvKU17ecmVkvIMl 6 | CIqA9t+1w3oS428+L50wyBh4F8h5haJAK23jQYWnMY84XPxdoxCRmlkpGLSV6kn2 7 | f04TVSN+uiSnmCtuikCbZwpxNJIyl0U1TdSXajsD7fWNo7Xo9kBploOuZFEEobz7 8 | 4erWiWdgxNirOWH0lmJq+6Cd/680xzky4/XQZWCBq59HVCp1UtjpUB+qAM6ny1pL 9 | uUBeXH15DGG8a84wtgwKfe9AGg6yvkAIKL5yeZU2hz56wJv+wjtjZh58M7pXwmhh 10 | 7PU6603pgGwQleCyml2//IJ91g8BzyOxmF0zqzpT7wmZyY6MvZAimIVXyK09TwGF 11 | rbnkTRjSf3FJnSiS/uLXEdiFu/U0fkJmUEuy4YBxajRVs07N1eJqbMNUKalBIzRc 12 | xeKYmbP+KXM5xB/Jby0lDfNK7po7wCUN+ZAjQP/b57QuYQzkKNEuZvUSK8Z3SgA9 13 | oKe4vfrKSND5jdWtFKpS7+aHshU7RSnTSK3g8L4Z0888G9MupvXS+lZbK9AeCfqx 14 | XOuGnnXdvf17FNx7Zg2fY6a1FKjHyP5/KfldKjJ/eBF0hS9lP18buQzgdbZcawYq 15 | TMd531Zes0JXMyLsWYEDlNjZBD1qmi8BRRKLAkuJOG3Tpbo= 16 | -----END X509 CRL----- 17 | -------------------------------------------------------------------------------- /synapse/data/certs/crls/The Vertex Project ROOT CA.crl: -------------------------------------------------------------------------------- 1 | -----BEGIN X509 CRL----- 2 | MIICXTBHMA0GCSqGSIb3DQEBCwUAMCUxIzAhBgNVBAMMGlRoZSBWZXJ0ZXggUHJv 3 | amVjdCBST09UIENBGA8yMDIyMTIwOTEyMzQxMlowDQYJKoZIhvcNAQELBQADggIB 4 | AHP1UDjy11aUxdDNMd1A6QKTMdor3lxrqKr1rX2zNZAz8ghwsLgWC6T6ohn3SS0Y 5 | HjHZWPOS45ojNSUAykXyUb/EnMwTgArHxs1rfyo+03brGfIPuGVfxtbz9aFQ0L6l 6 | 50OlHQXV3TZvzc3k5RLmCjXC/CFtMoqu9GyHtXEbpve0DpWdQqiJjN9CVlv8b5kc 7 | ojVNDOz0DOzJ/JxIbovSqmi+s+Ml3ChR+ydKeGj/bz3Fvf4eG1VUo4ZE0K1RxEBk 8 | Tx2sX21zlOlxjI8QyQgKHxneXCsOXXSez7hUVdFuBgxbJ1sb4qgBbdZ/fee3bgxn 9 | iOjmpjYu8NFWxx4L7ArOGWfzNWPWkKAoR60h8eF9CeOe7H68Up/E7ZOHmSyrTDtV 10 | Zgbq3QJj5xAB+j5M1IaYnFFuU1WcF+OVEKBQZu8a7nLaDlGo2Iy/nCOAeoATKGqP 11 | YsPd45zfP2rasdRcv4ZTMYhNqfrxmG+NTBmBV38uvD9a3UqFBEGgCuFETZiZTCZF 12 | oDBReayJD9/O2Jq4npMEfeUgxq2IFwNZUiRkzlV8J2i+kdwegAKaimWdgUVFMYmQ 13 | 52gR2Coy96EkWELzLifSSsB3f4B4SSrcaBNr92KAz23g4NtXVxld8crmVJAUwO9w 14 | BBOEKKCNrHAiwY7QxhD03cERYC0XrbBnHZb63ejHvRLE 15 | -----END X509 CRL----- 16 | -------------------------------------------------------------------------------- /synapse/data/iana.tlds.mpk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/synapse/data/iana.tlds.mpk -------------------------------------------------------------------------------- /synapse/data/iana.uris.mpk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/synapse/data/iana.uris.mpk -------------------------------------------------------------------------------- /synapse/data/jsonschemas/raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/common/binary.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/common/binary.json", 3 | "$schema": "http://json-schema.org/draft/2020-12/schema#", 4 | "title": "binary", 5 | "description": "The ​binary data type represents a sequence of bytes. In order to allow pattern matching on custom objects, for all properties that use the binary type, the property name MUST end with '_bin'. The JSON MTI serialization represents this as a base64-­encoded string as specified in RFC4648​. Other serializations SHOULD use a native binary type, if available.", 6 | "type": "string", 7 | "pattern": "^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$" 8 | } 9 | -------------------------------------------------------------------------------- /synapse/data/jsonschemas/raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/common/dictionary.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/common/dictionary.json", 3 | "$schema": "http://json-schema.org/draft/2020-12/schema#", 4 | "title": "dictionary", 5 | "description": "A dictionary captures a set of key/value pairs", 6 | "type": "object", 7 | "minProperties": 1, 8 | "patternProperties": { 9 | "^[a-zA-Z0-9_-]{0,250}$": { 10 | "anyOf": [ 11 | { 12 | "type": "array", 13 | "minItems": 1 14 | }, 15 | { 16 | "type": "string" 17 | }, 18 | { 19 | "type": "integer" 20 | }, 21 | { 22 | "type": "boolean" 23 | }, 24 | { 25 | "type": "number" 26 | }, 27 | { 28 | "type": "object" 29 | } 30 | ] 31 | } 32 | }, 33 | "additionalProperties": false 34 | } 35 | -------------------------------------------------------------------------------- /synapse/data/jsonschemas/raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/common/extension.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/common/extension.json", 3 | "$schema": "http://json-schema.org/draft/2020-12/schema#", 4 | "type": "object", 5 | "minProperties": 1, 6 | "properties": { 7 | "extension_type": { 8 | "description": "The type of extension.", 9 | "$ref": "#/definitions/extension-type-enum" 10 | } 11 | }, 12 | "allOf": [{ "$ref": "../common/properties.json" }], 13 | "required": [ 14 | "extension_type" 15 | ], 16 | "definitions": { 17 | "extension-type-enum": { 18 | "type": "string", 19 | "enum": [ 20 | "new-sdo", 21 | "new-sco", 22 | "new-sro", 23 | "property-extension", 24 | "toplevel-property-extension" 25 | ] 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /synapse/data/jsonschemas/raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/common/hex.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/common/hex.json", 3 | "$schema": "http://json-schema.org/draft/2020-12/schema#", 4 | "title": "hex", 5 | "description": "The hex data type encodes an array of octets (8-bit bytes) as hexadecimal. The string MUST consist of an even number of hexadecimal characters, which are the digits '0' through '9' and the letters 'a' through 'f'. In order to allow pattern matching on custom objects, all properties that use the hex type, the property name MUST end with '_hex'.", 6 | "type": "string", 7 | "pattern": "^([a-fA-F0-9]{2})+$" 8 | } 9 | -------------------------------------------------------------------------------- /synapse/data/jsonschemas/raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/common/identifier.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/common/identifier.json", 3 | "$schema": "http://json-schema.org/draft/2020-12/schema#", 4 | "title": "identifier", 5 | "description": "Represents identifiers across the CTI specifications. The format consists of the name of the top-level object being identified, followed by two dashes (--), followed by a UUIDv4.", 6 | "type": "string", 7 | "pattern": "^[a-z][a-z0-9-]+[a-z0-9]--[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$" 8 | } 9 | -------------------------------------------------------------------------------- /synapse/data/jsonschemas/raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/common/kill-chain-phase.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/common/kill-chain-phase.json", 3 | "$schema": "http://json-schema.org/draft/2020-12/schema#", 4 | "title": "kill-chain-phase", 5 | "description": "The kill-chain-phase represents a phase in a kill chain.", 6 | "type": "object", 7 | "properties": { 8 | "kill_chain_name": { 9 | "type": "string", 10 | "description": "The name of the kill chain." 11 | }, 12 | "phase_name": { 13 | "type": "string", 14 | "description": "The name of the phase in the kill chain." 15 | } 16 | }, 17 | "required": [ 18 | "kill_chain_name", 19 | "phase_name" 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /synapse/data/jsonschemas/raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/common/properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/common/properties.json", 3 | "$schema": "http://json-schema.org/draft/2020-12/schema#", 4 | "title": "properties", 5 | "description": "Rules for custom properties", 6 | "patternProperties": { 7 | "^[a-z][a-z0-9_]{0,245}_bin$": { 8 | "$ref": "../common/binary.json" 9 | }, 10 | "^[a-z][a-z0-9_]{0,245}_hex$": { 11 | "$ref": "../common/hex.json" 12 | }, 13 | "^([a-z][a-z0-9_]{2,249})|id$": { 14 | "anyOf": [ 15 | { 16 | "type": "array", 17 | "minItems": 1 18 | }, 19 | { 20 | "type": "string" 21 | }, 22 | { 23 | "type": "integer" 24 | }, 25 | { 26 | "type": "boolean" 27 | }, 28 | { 29 | "type": "number" 30 | }, 31 | { 32 | "type": "object" 33 | } 34 | ] 35 | } 36 | }, 37 | "additionalProperties": false 38 | } 39 | -------------------------------------------------------------------------------- /synapse/data/jsonschemas/raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/common/timestamp.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/common/timestamp.json", 3 | "$schema": "http://json-schema.org/draft/2020-12/schema#", 4 | "title": "timestamp", 5 | "description": "Represents timestamps across the CTI specifications. The format is an RFC3339 timestamp, with a required timezone specification of 'Z'.", 6 | "type": "string", 7 | "pattern": "^[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\\.[0-9]+)?Z$" 8 | } 9 | -------------------------------------------------------------------------------- /synapse/data/jsonschemas/raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/common/url-regex.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/common/url-regex.json", 3 | "$schema": "http://json-schema.org/draft/2020-12/schema#", 4 | "title": "url-regex", 5 | "description": "Matches a URI according to RFC 3986.", 6 | "type": "string", 7 | "format": "uri" 8 | } 9 | -------------------------------------------------------------------------------- /synapse/data/jsonschemas/raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/observables/domain-name.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/observables/domain-name.json", 3 | "$schema": "http://json-schema.org/draft/2020-12/schema#", 4 | "title": "domain-name", 5 | "description": "The Domain Name represents the properties of a network domain name.", 6 | "type": "object", 7 | "allOf": [ 8 | { 9 | "$ref": "../common/cyber-observable-core.json" 10 | }, 11 | { 12 | "properties": { 13 | "type": { 14 | "type": "string", 15 | "description": "The value of this property MUST be `domain-name`.", 16 | "enum": [ 17 | "domain-name" 18 | ] 19 | }, 20 | "id": { 21 | "title": "id", 22 | "pattern": "^domain-name--" 23 | }, 24 | "value": { 25 | "type": "string", 26 | "description": "Specifies the value of the domain name.", 27 | "format": "idn-hostname" 28 | }, 29 | "resolves_to_refs": { 30 | "type": "array", 31 | "description": "Specifies a list of references to one or more IP addresses or domain names that the domain name resolves to.", 32 | "items": { 33 | "type": "string" 34 | }, 35 | "minItems": 1 36 | } 37 | }, 38 | "required": [ 39 | "value" 40 | ] 41 | } 42 | ] 43 | } 44 | -------------------------------------------------------------------------------- /synapse/data/jsonschemas/raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/observables/mac-addr.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/observables/mac-addr.json", 3 | "$schema": "http://json-schema.org/draft/2020-12/schema#", 4 | "title": "mac-addr", 5 | "description": "The MAC Address Object represents a single Media Access Control (MAC) address.", 6 | "type": "object", 7 | "allOf": [ 8 | { 9 | "$ref": "../common/cyber-observable-core.json" 10 | }, 11 | { 12 | "properties": { 13 | "type": { 14 | "type": "string", 15 | "description": "The value of this property MUST be `mac-addr`.", 16 | "enum": [ 17 | "mac-addr" 18 | ] 19 | }, 20 | "id": { 21 | "title": "id", 22 | "pattern": "^mac-addr--" 23 | }, 24 | "value": { 25 | "type": "string", 26 | "pattern": "^([0-9a-f]{2}[:]){5}([0-9a-f]{2})$", 27 | "description": "Specifies one or more mac addresses expressed using CIDR notation." 28 | } 29 | }, 30 | "required": [ 31 | "value" 32 | ] 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /synapse/data/jsonschemas/raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/observables/mutex.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/observables/mutex.json", 3 | "$schema": "http://json-schema.org/draft/2020-12/schema#", 4 | "title": "mutex", 5 | "description": "The Mutex Object represents the properties of a mutual exclusion (mutex) object.", 6 | "type": "object", 7 | "allOf": [ 8 | { 9 | "$ref": "../common/cyber-observable-core.json" 10 | }, 11 | { 12 | "properties": { 13 | "type": { 14 | "type": "string", 15 | "description": "The value of this property MUST be `mutex`.", 16 | "enum": [ 17 | "mutex" 18 | ] 19 | }, 20 | "id": { 21 | "title": "id", 22 | "pattern": "^mutex--" 23 | }, 24 | "name": { 25 | "type": "string", 26 | "description": "Specifies the name of the mutex object." 27 | } 28 | } 29 | } 30 | ], 31 | "required": [ 32 | "name" 33 | ] 34 | } 35 | -------------------------------------------------------------------------------- /synapse/data/jsonschemas/raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/observables/url.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/observables/url.json", 3 | "$schema": "http://json-schema.org/draft/2020-12/schema#", 4 | "title": "url", 5 | "description": "The URL Object represents the properties of a uniform resource locator (URL).", 6 | "type": "object", 7 | "allOf": [ 8 | { 9 | "$ref": "../common/cyber-observable-core.json" 10 | }, 11 | { 12 | "properties": { 13 | "type": { 14 | "type": "string", 15 | "description": "The value of this property MUST be `url`.", 16 | "enum": [ 17 | "url" 18 | ] 19 | }, 20 | "id": { 21 | "title": "id", 22 | "pattern": "^url--" 23 | }, 24 | "value": { 25 | "$ref": "../common/url-regex.json", 26 | "description": "Specifies the value of the URL." 27 | } 28 | } 29 | } 30 | ], 31 | "required": [ 32 | "value" 33 | ] 34 | } 35 | -------------------------------------------------------------------------------- /synapse/data/jsonschemas/raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/sdos/course-of-action.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/sdos/course-of-action.json", 3 | "$schema": "http://json-schema.org/draft/2020-12/schema#", 4 | "title": "course-of-action", 5 | "description": "A Course of Action is an action taken either to prevent an attack or to respond to an attack that is in progress. ", 6 | "type": "object", 7 | "allOf": [ 8 | { 9 | "$ref": "../common/core.json" 10 | }, 11 | { 12 | "properties": { 13 | "type": { 14 | "type": "string", 15 | "description": "The type of this object, which MUST be the literal `course-of-action`.", 16 | "enum": [ 17 | "course-of-action" 18 | ] 19 | }, 20 | "id": { 21 | "title": "id", 22 | "pattern": "^course-of-action--" 23 | }, 24 | "name": { 25 | "type": "string", 26 | "description": "The name used to identify the Course of Action." 27 | }, 28 | "description": { 29 | "type": "string", 30 | "description": "A description that provides more details and context about this object, potentially including its purpose and its key characteristics." 31 | } 32 | } 33 | } 34 | ], 35 | "required": [ 36 | "name" 37 | ] 38 | } 39 | -------------------------------------------------------------------------------- /synapse/data/jsonschemas/raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/sdos/incident.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/sdos/incident.json", 3 | "$schema": "http://json-schema.org/draft/2020-12/schema#", 4 | "title": "incident", 5 | "description": "The Incident object in STIX 2.1 is a stub, to be expanded in future STIX 2 releases.", 6 | "type": "object", 7 | "allOf": [ 8 | { 9 | "$ref": "../common/core.json" 10 | }, 11 | { 12 | "properties": { 13 | "type": { 14 | "type": "string", 15 | "description": "The type of this object, which MUST be the literal `incident`.", 16 | "enum": [ 17 | "incident" 18 | ] 19 | }, 20 | "id": { 21 | "title": "id", 22 | "pattern": "^incident--" 23 | }, 24 | "name": { 25 | "type": "string", 26 | "description": "The name used to identify the Incident." 27 | }, 28 | "description": { 29 | "type": "string", 30 | "description": "A description that provides more details and context about the Incident." 31 | } 32 | } 33 | } 34 | ], 35 | "required": [ 36 | "name" 37 | ] 38 | } 39 | -------------------------------------------------------------------------------- /synapse/data/jsonschemas/raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/sdos/vulnerability.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/sdos/vulnerability.json", 3 | "$schema": "http://json-schema.org/draft/2020-12/schema#", 4 | "title": "vulnerability", 5 | "description": "A Vulnerability is a mistake in software that can be directly used by a hacker to gain access to a system or network.", 6 | "type": "object", 7 | "allOf": [ 8 | { 9 | "$ref": "../common/core.json" 10 | }, 11 | { 12 | "properties": { 13 | "type": { 14 | "type": "string", 15 | "description": "The type of this object, which MUST be the literal `vulnerability`.", 16 | "enum": [ 17 | "vulnerability" 18 | ] 19 | }, 20 | "id": { 21 | "title": "id", 22 | "pattern": "^vulnerability--" 23 | }, 24 | "name": { 25 | "type": "string", 26 | "description": "The name used to identify the Vulnerability." 27 | }, 28 | "description": { 29 | "type": "string", 30 | "description": "A description that provides more details and context about the Vulnerability." 31 | } 32 | } 33 | } 34 | ], 35 | "required": [ 36 | "name" 37 | ] 38 | } 39 | -------------------------------------------------------------------------------- /synapse/lib/__init__.py: -------------------------------------------------------------------------------- 1 | # This __init__.py should remain empty so importing individual modules from 2 | # synapse.lib does not have unexpected side effects. 3 | -------------------------------------------------------------------------------- /synapse/lib/const.py: -------------------------------------------------------------------------------- 1 | # Logging related constants 2 | import logging 3 | 4 | LOG_FORMAT = '%(asctime)s [%(levelname)s] %(message)s ' \ 5 | '[%(filename)s:%(funcName)s:%(threadName)s:%(processName)s]' 6 | LOG_LEVEL_CHOICES = { 7 | 'DEBUG': logging.DEBUG, 8 | 'INFO': logging.INFO, 9 | 'WARNING': logging.WARNING, 10 | 'ERROR': logging.ERROR, 11 | 'CRITICAL': logging.CRITICAL, 12 | } 13 | LOG_LEVEL_INVERSE_CHOICES = {v: k for k, v in LOG_LEVEL_CHOICES.items()} 14 | 15 | # Math related constants 16 | kilobyte = 1000 17 | megabyte = 1000 * kilobyte 18 | gigabyte = 1000 * megabyte 19 | terabyte = 1000 * gigabyte 20 | petabyte = 1000 * terabyte 21 | exabyte = 1000 * petabyte 22 | zettabyte = 1000 * exabyte 23 | yottabyte = 1000 * zettabyte 24 | 25 | kibibyte = 1024 26 | mebibyte = 1024 * kibibyte 27 | gibibyte = 1024 * mebibyte 28 | tebibyte = 1024 * gibibyte 29 | pebibyte = 1024 * tebibyte 30 | exbibyte = 1024 * pebibyte 31 | zebibyte = 1024 * exbibyte 32 | yobibyte = 1024 * zebibyte 33 | 34 | # time (in millis) constants 35 | second = 1000 36 | minute = second * 60 37 | hour = minute * 60 38 | day = hour * 24 39 | week = day * 7 40 | month = day * 30 41 | year = day * 365 42 | 43 | # function specific constants shared across multiple files 44 | layer_pdef_csize = 1_000 45 | layer_pdef_qsize = 10_000 46 | layer_pdef_csize_max = 1_000 47 | layer_pdef_qsize_max = 10_000 48 | assert layer_pdef_csize <= layer_pdef_csize_max 49 | assert layer_pdef_qsize <= layer_pdef_qsize_max 50 | -------------------------------------------------------------------------------- /synapse/lib/crypto/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/synapse/lib/crypto/__init__.py -------------------------------------------------------------------------------- /synapse/lib/datfile.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Utilities for handling data files embedded within python packages. 3 | ''' 4 | import os 5 | 6 | import synapse.lib.dyndeps as s_dyndeps 7 | 8 | def openDatFile(datpath): 9 | ''' 10 | Open a file-like object using a pkg relative path. 11 | 12 | Example: 13 | 14 | fd = openDatFile('foopkg.barpkg/wootwoot.bin') 15 | ''' 16 | pkgname, filename = datpath.split('/', 1) 17 | 18 | pkgmod = s_dyndeps.getDynMod(pkgname) 19 | 20 | # are we a regular file? 21 | pkgfile = os.path.abspath(pkgmod.__file__) 22 | if os.path.isfile(pkgfile): 23 | dirname = os.path.dirname(pkgfile) 24 | datname = os.path.join(dirname, filename) 25 | return open(datname, 'rb') 26 | -------------------------------------------------------------------------------- /synapse/lib/hashitem.py: -------------------------------------------------------------------------------- 1 | import types 2 | 3 | import synapse.common as s_common 4 | 5 | def hashitem(item): 6 | ''' 7 | Generate a uniq hash for the JSON compatible primitive data structure. 8 | ''' 9 | norm = normitem(item) 10 | return s_common.guid(norm) 11 | 12 | def normitem(item): 13 | normer = normers.get(type(item)) 14 | if normer: 15 | return normer(item) 16 | 17 | return item 18 | 19 | def normdict(item): 20 | return tuple(sorted([(normitem(key), normitem(val)) for key, val in item.items() if val is not None])) 21 | 22 | def normiter(item): 23 | return tuple([normitem(i) for i in item if i is not None]) 24 | 25 | normers = { 26 | dict: normdict, 27 | list: normiter, 28 | tuple: normiter, 29 | types.GeneratorType: normiter, 30 | } 31 | -------------------------------------------------------------------------------- /synapse/lib/ingest.py: -------------------------------------------------------------------------------- 1 | # This file is reserved for future use. 2 | -------------------------------------------------------------------------------- /synapse/lib/interval.py: -------------------------------------------------------------------------------- 1 | ''' 2 | A few utilities for dealing with intervals. 3 | ''' 4 | import synapse.lib.time as s_time 5 | 6 | def fold(*vals): 7 | ''' 8 | Initialize a new (min,max) tuple interval from values. 9 | 10 | Args: 11 | *vals ([int,...]): A list of values (or Nones) 12 | 13 | Returns: 14 | ((int,int)): A (min,max) interval tuple or None 15 | 16 | ''' 17 | vals = [v for v in vals if v is not None] 18 | if not vals: 19 | return None 20 | return min(vals), max(vals) 21 | 22 | def overlap(ival0, ival1): 23 | ''' 24 | Determine if two interval tuples have overlap. 25 | 26 | Args: 27 | ival0 ((int,int)): An interval tuple 28 | ival1 ((int,int)); An interval tuple 29 | 30 | Returns: 31 | (bool): True if the intervals overlap, otherwise False 32 | 33 | ''' 34 | min0, max0 = ival0 35 | min1, max1 = ival1 36 | return max(0, min(max0, max1) - max(min0, min1)) > 0 37 | 38 | def parsetime(text): 39 | ''' 40 | Parse an interval time string and return a (min,max) tuple. 41 | 42 | Args: 43 | text (str): A time interval string 44 | 45 | Returns: 46 | ((int,int)): A epoch millis epoch time string 47 | 48 | ''' 49 | mins, maxs = text.split('-', 1) 50 | minv = s_time.parse(mins) 51 | maxv = s_time.parse(maxs, base=minv) 52 | return minv, maxv 53 | -------------------------------------------------------------------------------- /synapse/lib/modules.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Module which implements the synapse module API/convention. 3 | ''' 4 | coremods = ( 5 | 'synapse.models.doc.DocModule', 6 | 'synapse.models.dns.DnsModule', 7 | 'synapse.models.orgs.OuModule', 8 | 'synapse.models.syn.SynModule', 9 | 'synapse.models.auth.AuthModule', 10 | 'synapse.models.base.BaseModule', 11 | 'synapse.models.math.MathModule', 12 | 'synapse.models.risk.RiskModule', 13 | 'synapse.models.person.PsModule', 14 | 'synapse.models.files.FileModule', 15 | 'synapse.models.infotech.ItModule', 16 | 'synapse.models.geospace.GeoModule', 17 | 'synapse.models.media.MediaModule', 18 | 'synapse.models.geopol.PolModule', 19 | 'synapse.models.telco.TelcoModule', 20 | 'synapse.models.inet.InetModule', 21 | 'synapse.models.material.MatModule', 22 | 'synapse.models.entity.EntityModule', 23 | 'synapse.models.language.LangModule', 24 | 'synapse.models.crypto.CryptoModule', 25 | 'synapse.models.gov.cn.GovCnModule', 26 | 'synapse.models.gov.us.GovUsModule', 27 | 'synapse.models.gov.intl.GovIntlModule', 28 | 'synapse.models.economic.EconModule', 29 | 'synapse.models.transport.TransportModule', 30 | 'synapse.models.proj.ProjectModule', 31 | 'synapse.models.biz.BizModule', 32 | 'synapse.models.belief.BeliefModule', 33 | 'synapse.models.science.ScienceModule', 34 | 'synapse.models.planning.PlanModule', 35 | ) 36 | -------------------------------------------------------------------------------- /synapse/lib/output.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Tools for easily hookable output from cli-like tools. 3 | ''' 4 | import io 5 | import sys 6 | 7 | class OutPut: 8 | 9 | def __init__(self): 10 | pass 11 | 12 | def printf(self, mesg, addnl=True): 13 | 14 | if addnl: 15 | mesg += '\n' 16 | 17 | return self._rawOutPut(mesg) 18 | 19 | def _rawOutPut(self, mesg): 20 | sys.stdout.write(mesg) 21 | 22 | class OutPutFd(OutPut): 23 | 24 | def __init__(self, fd, enc='utf8'): 25 | OutPut.__init__(self) 26 | self.fd = fd 27 | self.enc = enc 28 | 29 | def _rawOutPut(self, mesg): 30 | self.fd.write(mesg.encode(self.enc)) 31 | 32 | class OutPutBytes(OutPutFd): 33 | 34 | def __init__(self): 35 | OutPutFd.__init__(self, io.BytesIO()) 36 | 37 | class OutPutStr(OutPut): 38 | 39 | def __init__(self): 40 | OutPut.__init__(self) 41 | self.mesgs = [] 42 | 43 | def _rawOutPut(self, mesg): 44 | self.mesgs.append(mesg) 45 | 46 | def __str__(self): 47 | return ''.join(self.mesgs) 48 | 49 | stdout = OutPut() 50 | -------------------------------------------------------------------------------- /synapse/lib/platforms/__init__.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Home for platform specific code such as thishost info. 3 | 4 | *all* platform modules *must* be importable from any platform. 5 | 6 | ( guard any platform specific code with appropriate conditionals ) 7 | 8 | ''' 9 | -------------------------------------------------------------------------------- /synapse/lib/platforms/common.py: -------------------------------------------------------------------------------- 1 | import os 2 | import socket 3 | import ctypes 4 | import logging 5 | import tempfile 6 | 7 | import ctypes.util as c_util 8 | 9 | logger = logging.getLogger(__name__) 10 | 11 | def setProcName(name): 12 | ''' 13 | Set the process title/name for process listing. 14 | ''' 15 | logger.info('setProcName: %s' % (name,)) 16 | 17 | def getVolInfo(*paths): 18 | ''' 19 | Retrieve volume usage info for the given path. 20 | ''' 21 | path = os.path.join(*paths) 22 | path = os.path.expanduser(path) 23 | 24 | st = os.statvfs(path) 25 | 26 | free = st.f_bavail * st.f_frsize 27 | total = st.f_blocks * st.f_frsize 28 | 29 | return { 30 | 'free': free, 31 | 'used': total - free, 32 | 'total': total, 33 | } 34 | 35 | def inet_pton(afam, text): 36 | return socket.inet_pton(afam, text) 37 | 38 | def inet_ntop(afam, byts): 39 | return socket.inet_ntop(afam, byts) 40 | 41 | def daemonize(): 42 | ''' 43 | For unix platforms, form a new process group using fork(). 44 | ''' 45 | if os.fork() != 0: 46 | exit() 47 | 48 | if os.fork() != 0: 49 | exit() 50 | 51 | def getLibC(): 52 | ''' 53 | Return a ctypes reference to libc 54 | ''' 55 | return ctypes.CDLL(c_util.find_library('c'), use_errno=True) 56 | 57 | def initHostInfo(): 58 | return {} 59 | 60 | def getTempDir(): 61 | return tempfile.gettempdir() 62 | -------------------------------------------------------------------------------- /synapse/lib/platforms/darwin.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | logger = logging.getLogger(__name__) 4 | 5 | def initHostInfo(): 6 | return { 7 | 'format': 'macho', 8 | 'platform': 'darwin', 9 | } 10 | -------------------------------------------------------------------------------- /synapse/lib/platforms/freebsd.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | logger = logging.getLogger(__name__) 4 | 5 | def initHostInfo(): 6 | return { 7 | 'format': 'elf', 8 | 'platform': 'freebsd', 9 | } 10 | -------------------------------------------------------------------------------- /synapse/lib/ratelimit.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | class RateLimit: 4 | ''' 5 | A RateLimit class may be used to detect/enforce rate limits. 6 | 7 | Example: 8 | 9 | # allow 20 uses per 10 sec ( 2/sec ) 10 | rlimit = RateLimit(20,10) 11 | 12 | Notes: 13 | 14 | It is best ( even in a "calls per day" type config ) to 15 | specify a smaller "per" to force rate "smoothing". 16 | 17 | ''' 18 | def __init__(self, rate, per): 19 | self.rate = float(rate) 20 | self.per = float(per) 21 | 22 | self.lasttick = time.time() 23 | self.allowance = float(rate) 24 | 25 | self.persec = float(rate) / float(per) 26 | self.onetick = float(per) / float(rate) 27 | 28 | def allows(self): 29 | ''' 30 | Returns True if the rate limit has not been reached. 31 | 32 | Example: 33 | 34 | if not rlimit.allows(): 35 | rasie RateExceeded() 36 | 37 | # ok to go... 38 | 39 | ''' 40 | tick = time.time() 41 | passed = tick - self.lasttick 42 | 43 | self.allowance = min(self.rate, self.allowance + (passed * self.persec)) 44 | 45 | self.lasttick = tick 46 | 47 | if self.allowance < 1.0: 48 | return False 49 | 50 | self.allowance -= 1.0 51 | return True 52 | -------------------------------------------------------------------------------- /synapse/lib/share.py: -------------------------------------------------------------------------------- 1 | import synapse.common as s_common 2 | 3 | import synapse.lib.base as s_base 4 | 5 | class Share(s_base.Base): 6 | ''' 7 | Class to wrap a dynamically shared object. 8 | ''' 9 | async def __anit__(self, link, item): 10 | await s_base.Base.__anit__(self) 11 | 12 | self.link = link 13 | 14 | self.orig = item # for context management 15 | self.item = item 16 | 17 | self.iden = s_common.guid() 18 | 19 | sess = link.get('sess') 20 | 21 | async def fini(): 22 | sess.popSessItem(self.iden) 23 | 24 | self.onfini(fini) 25 | 26 | sess.setSessItem(self.iden, self) 27 | 28 | async def _runShareLoop(self): 29 | return 30 | -------------------------------------------------------------------------------- /synapse/lib/slaboffs.py: -------------------------------------------------------------------------------- 1 | import synapse.common as s_common 2 | 3 | import synapse.lib.lmdbslab as s_lmdbslab 4 | 5 | class SlabOffs: 6 | ''' 7 | A helper for storing offset integers by iden. 8 | 9 | As with all slab objects, this is meant for single-thread async loop use. 10 | ''' 11 | def __init__(self, slab: s_lmdbslab.Slab, db: str) -> None: 12 | self.db = slab.initdb(db) 13 | self.slab = slab 14 | 15 | def get(self, iden): 16 | 17 | buid = s_common.uhex(iden) 18 | 19 | byts = self.slab.get(buid, db=self.db) 20 | if byts is None: 21 | return 0 22 | 23 | return s_common.int64un(byts) 24 | 25 | def set(self, iden, offs): 26 | buid = s_common.uhex(iden) 27 | byts = s_common.int64en(offs) 28 | self.slab.put(buid, byts, db=self.db) 29 | 30 | def delete(self, iden): 31 | buid = s_common.uhex(iden) 32 | self.slab.delete(buid, db=self.db) 33 | -------------------------------------------------------------------------------- /synapse/lib/stormlib/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/synapse/lib/stormlib/__init__.py -------------------------------------------------------------------------------- /synapse/lib/stormlib/ethereum.py: -------------------------------------------------------------------------------- 1 | import synapse.lib.crypto.coin as s_coin 2 | import synapse.lib.stormtypes as s_stormtypes 3 | 4 | @s_stormtypes.registry.registerLib 5 | class EthereumLib(s_stormtypes.Lib): 6 | ''' 7 | A Storm library which implements helpers for Ethereum. 8 | ''' 9 | _storm_locals = ( 10 | {'name': 'eip55', 'desc': 'Convert an Ethereum address to a checksummed address.', 11 | 'type': {'type': 'function', '_funcname': 'eip55', 12 | 'args': ( 13 | {'name': 'addr', 'type': 'str', 'desc': 'The Ethereum address to be converted.'}, 14 | ), 15 | 'returns': {'type': 'list', 16 | 'desc': 'A list of (, ) for status and checksummed address.', }, 17 | }}, 18 | ) 19 | 20 | _storm_lib_path = ('crypto', 'coin', 'ethereum') 21 | 22 | def getObjLocals(self): 23 | return { 24 | 'eip55': self.eip55, 25 | } 26 | 27 | @s_stormtypes.stormfunc(readonly=True) 28 | async def eip55(self, addr): 29 | addr = await s_stormtypes.tostr(addr) 30 | addr = addr.lower() 31 | if addr.startswith('0x'): 32 | addr = addr[2:] 33 | 34 | csum = s_coin.ether_eip55(addr) 35 | if csum is not None: 36 | return (True, csum) 37 | return (False, None) 38 | -------------------------------------------------------------------------------- /synapse/lib/stormlib/math.py: -------------------------------------------------------------------------------- 1 | import synapse.lib.stormtypes as s_stormtypes 2 | 3 | @s_stormtypes.registry.registerLib 4 | class MathLib(s_stormtypes.Lib): 5 | ''' 6 | A Storm library for performing math operations. 7 | ''' 8 | _storm_locals = ( 9 | {'name': 'number', 10 | 'desc': ''' 11 | Convert a value to a Storm Number object. 12 | 13 | Storm Numbers are high precision fixed point decimals corresponding to 14 | the hugenum storage type. 15 | 16 | This is not to be used for converting a string to an integer. 17 | ''', 18 | 'type': {'type': 'function', '_funcname': '_number', 19 | 'args': ( 20 | {'name': 'value', 'type': 'any', 21 | 'desc': 'Value to convert.', }, 22 | ), 23 | 'returns': {'type': 'number', 'desc': 'A Number object.', }}}, 24 | ) 25 | 26 | _storm_lib_path = ('math',) 27 | 28 | def getObjLocals(self): 29 | return { 30 | 'number': self._number, 31 | } 32 | 33 | @s_stormtypes.stormfunc(readonly=True) 34 | async def _number(self, value): 35 | if isinstance(value, s_stormtypes.Number): 36 | return value 37 | return s_stormtypes.Number(value) 38 | -------------------------------------------------------------------------------- /synapse/lib/stormlib/mime.py: -------------------------------------------------------------------------------- 1 | import bs4 2 | 3 | import synapse.lib.coro as s_coro 4 | import synapse.lib.stormtypes as s_stormtypes 5 | 6 | def htmlToText(html): 7 | soup = bs4.BeautifulSoup(html, 'html5lib') 8 | return soup.get_text(separator='\n', strip=True) 9 | 10 | @s_stormtypes.registry.registerLib 11 | class LibMimeHtml(s_stormtypes.Lib): 12 | ''' 13 | A Storm library for manipulating HTML text. 14 | ''' 15 | _storm_locals = ( 16 | {'name': 'totext', 'desc': 'Return inner text from all tags within an HTML document.', 17 | 'type': {'type': 'function', '_funcname': 'totext', 18 | 'args': ( 19 | {'name': 'html', 'type': 'str', 'desc': 'The HTML text to be parsed.'}, 20 | ), 21 | 'returns': {'type': 'str', 'desc': 'The newline-joined inner HTML text.', } 22 | }}, 23 | ) 24 | 25 | _storm_lib_path = ('mime', 'html') 26 | 27 | def getObjLocals(self): 28 | return { 29 | 'totext': self.totext, 30 | } 31 | 32 | @s_stormtypes.stormfunc(readonly=True) 33 | async def totext(self, html): 34 | html = await s_stormtypes.tostr(html) 35 | return await s_coro.semafork(htmlToText, html) 36 | -------------------------------------------------------------------------------- /synapse/lib/stormlib/utils.py: -------------------------------------------------------------------------------- 1 | import synapse.lib.stormtypes as s_stormtypes 2 | 3 | @s_stormtypes.registry.registerLib 4 | class LibUtils(s_stormtypes.Lib): 5 | ''' 6 | A Storm library for working with utility functions. 7 | ''' 8 | _storm_locals = ( 9 | {'name': 'todo', 10 | 'desc': ''' 11 | Create a todo tuple of (name, args, kwargs). 12 | ''', 13 | 'type': {'type': 'function', '_funcname': '_todo', 14 | 'args': ( 15 | {'name': '_todoname', 'type': 'str', 16 | 'desc': 'The todo name.'}, 17 | {'name': '*args', 'type': 'any', 18 | 'desc': 'Positional arguments for the todo.'}, 19 | {'name': '**kwargs', 'type': 'any', 20 | 'desc': 'Keyword arguments for the todo.'}, 21 | ), 22 | 'returns': {'type': 'list', 'desc': 'A todo tuple of (name, args, kwargs).'}, 23 | }}, 24 | ) 25 | _storm_lib_path = ('utils',) 26 | 27 | def getObjLocals(self): 28 | return { 29 | 'todo': self._todo, 30 | } 31 | 32 | @s_stormtypes.stormfunc(readonly=True) 33 | async def _todo(self, _todoname, *args, **kwargs): 34 | _todoname = await s_stormtypes.tostr(_todoname) 35 | args = await s_stormtypes.toprim(args) 36 | kwargs = await s_stormtypes.toprim(kwargs) 37 | return (_todoname, args, kwargs) 38 | -------------------------------------------------------------------------------- /synapse/lib/structlog.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | import synapse.common as s_common 4 | 5 | import synapse.lib.json as s_json 6 | 7 | class JsonFormatter(logging.Formatter): 8 | def __init__(self, *args, **kwargs): 9 | super().__init__(*args, **kwargs) 10 | 11 | def format(self, record: logging.LogRecord): 12 | 13 | record.message = record.getMessage() 14 | mesg = self.formatMessage(record) 15 | ret = { 16 | 'message': mesg, 17 | 'logger': { 18 | 'name': record.name, 19 | 'process': record.processName, 20 | 'filename': record.filename, 21 | 'func': record.funcName, 22 | }, 23 | 'level': record.levelname, 24 | 'time': self.formatTime(record, self.datefmt), 25 | } 26 | 27 | if record.exc_info: 28 | name, info = s_common.err(record.exc_info[1], fulltb=True) 29 | # This is the actual exception name. The ename key is the function name. 30 | info['errname'] = name 31 | ret['err'] = info 32 | 33 | # stuffing our extra into a single dictionary avoids a loop 34 | # over record.__dict__ extracting fields which are not known 35 | # attributes for each log record. 36 | extras = record.__dict__.get('synapse') 37 | if extras: 38 | ret.update({k: v for k, v in extras.items() if k not in ret}) 39 | 40 | return s_json.dumps(ret, default=str).decode() 41 | -------------------------------------------------------------------------------- /synapse/lib/thishost.py: -------------------------------------------------------------------------------- 1 | import ctypes 2 | import socket 3 | 4 | import synapse.lib.thisplat as s_thisplat 5 | 6 | hostinfo = s_thisplat.initHostInfo() 7 | hostinfo['ptrsize'] = ctypes.sizeof(ctypes.c_void_p) 8 | hostinfo['hostname'] = socket.gethostname() 9 | 10 | def get(prop): 11 | ''' 12 | Retrieve a property from the hostinfo dictionary. 13 | 14 | 15 | Example: 16 | 17 | import synapse.lib.thishost as s_thishost 18 | 19 | if s_thishost.get('platform') == 'windows': 20 | dostuff() 21 | 22 | 23 | ''' 24 | return hostinfo.get(prop) 25 | 26 | def hostaddr(dest='8.8.8.8'): 27 | ''' 28 | Retrieve the ipv4 address for this host ( optionally as seen from dest ). 29 | Example: 30 | addr = s_socket.hostaddr() 31 | ''' 32 | sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 33 | 34 | # doesn't actually send any packets! 35 | sock.connect((dest, 80)) 36 | addr, port = sock.getsockname() 37 | 38 | sock.close() 39 | 40 | return addr 41 | -------------------------------------------------------------------------------- /synapse/lib/thisplat.py: -------------------------------------------------------------------------------- 1 | import ctypes 2 | import platform 3 | 4 | from synapse.lib.platforms.common import * 5 | 6 | sysname = platform.system().lower() 7 | if sysname == 'darwin': 8 | from synapse.lib.platforms.darwin import * 9 | 10 | elif sysname == 'linux': 11 | from synapse.lib.platforms.linux import * 12 | 13 | elif sysname == 'freebsd': 14 | from synapse.lib.platforms.freebsd import * 15 | 16 | elif getattr(ctypes, 'windll', None): 17 | from synapse.lib.platforms.windows import * 18 | -------------------------------------------------------------------------------- /synapse/lib/threads.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import threading 3 | 4 | logger = logging.getLogger(__name__) 5 | 6 | def current(): 7 | return threading.current_thread() 8 | 9 | def iden(): 10 | return current().ident 11 | -------------------------------------------------------------------------------- /synapse/lookup/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/synapse/lookup/__init__.py -------------------------------------------------------------------------------- /synapse/lookup/timezones.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Timezones are defined per RFC822 5.1 (plus GMT and UTC), 3 | with values representing offsets from UTC in milliseconds. 4 | ''' 5 | import types 6 | 7 | import synapse.exc as s_exc 8 | 9 | _onehour = 3600000 10 | 11 | _timezones = types.MappingProxyType({ 12 | 'A': -1 * _onehour, 13 | 'CDT': -5 * _onehour, 14 | 'CST': -6 * _onehour, 15 | 'EDT': -4 * _onehour, 16 | 'EST': -5 * _onehour, 17 | 'GMT': 0, 18 | 'M': -12 * _onehour, 19 | 'MDT': -6 * _onehour, 20 | 'MST': -7 * _onehour, 21 | 'N': 1 * _onehour, 22 | 'PDT': -7 * _onehour, 23 | 'PST': -8 * _onehour, 24 | 'UT': 0, 25 | 'UTC': 0, 26 | 'Y': 12 * _onehour, 27 | 'Z': 0, 28 | }) 29 | 30 | def getTzNames(): 31 | ''' 32 | Return a tuple of all supported timezone names. 33 | ''' 34 | return tuple(_timezones.keys()) 35 | 36 | def getTzOffset(name, defval=None): 37 | ''' 38 | Return tuple of the UTC offset in milliseconds and an info dict. 39 | ''' 40 | try: 41 | return _timezones.get(name.upper(), defval), {} 42 | except AttributeError: 43 | raise s_exc.BadArg(mesg=f'Timezone name must a string') from None 44 | -------------------------------------------------------------------------------- /synapse/mindmeld.py: -------------------------------------------------------------------------------- 1 | # reserved for future use 2 | -------------------------------------------------------------------------------- /synapse/models/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/synapse/models/__init__.py -------------------------------------------------------------------------------- /synapse/models/gov/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/synapse/models/gov/__init__.py -------------------------------------------------------------------------------- /synapse/models/gov/cn.py: -------------------------------------------------------------------------------- 1 | import synapse.lib.module as s_module 2 | 3 | class GovCnModule(s_module.CoreModule): 4 | 5 | def getModelDefs(self): 6 | modl = { 7 | 'types': ( 8 | ('gov:cn:icp', 9 | ('int', {}), 10 | {'doc': 'A Chinese Internet Content Provider ID.'}, 11 | ), 12 | ('gov:cn:mucd', 13 | ('int', {}), 14 | {'doc': 'A Chinese PLA MUCD.'}, 15 | ), 16 | ), 17 | 'forms': ( 18 | ('gov:cn:icp', {}, ( 19 | ('org', ('ou:org', {}), { 20 | 'doc': 'The org with the Internet Content Provider ID.', 21 | }), 22 | )), 23 | # TODO - Add 'org' as a secondary property to mcud? 24 | ('gov:cn:mucd', {}, ()), 25 | ) 26 | } 27 | name = 'gov:cn' 28 | return ((name, modl), ) 29 | -------------------------------------------------------------------------------- /synapse/models/gov/intl.py: -------------------------------------------------------------------------------- 1 | import synapse.lib.module as s_module 2 | 3 | class GovIntlModule(s_module.CoreModule): 4 | 5 | def getModelDefs(self): 6 | modl = { 7 | 'types': ( 8 | ('iso:oid', ('str', {'regex': '^([0-2])((\\.0)|(\\.[1-9][0-9]*))*$'}), { 9 | 'doc': 'An ISO Object Identifier string.'}), 10 | 11 | ('iso:3166:cc', ('str', {'lower': True, 'regex': '^[a-z]{2}$'}), { 12 | 'doc': 'An ISO 3166 2 digit country code.'}), 13 | 14 | ('gov:intl:un:m49', ('int', {'min': 1, 'max': 999}), { 15 | 'doc': 'UN M49 Numeric Country Code.'}), 16 | ), 17 | 18 | 'forms': ( 19 | ('iso:oid', {}, ( 20 | ('descr', ('str', {}), { 21 | 'doc': 'A description of the value or meaning of the OID.'}), 22 | ('identifier', ('str', {}), { 23 | 'doc': 'The string identifier for the deepest tree element.'}), 24 | )), 25 | ), 26 | } 27 | name = 'gov:intl' 28 | return ((name, modl), ) 29 | -------------------------------------------------------------------------------- /synapse/models/gov/us.py: -------------------------------------------------------------------------------- 1 | import synapse.lib.module as s_module 2 | 3 | class GovUsModule(s_module.CoreModule): 4 | 5 | def getModelDefs(self): 6 | modl = { 7 | 'types': ( 8 | ('gov:us:ssn', ('int', {}), {'doc': 'A US Social Security Number (SSN).'}), 9 | ('gov:us:zip', ('int', {}), {'doc': 'A US Postal Zip Code.'}), 10 | ('gov:us:cage', ('str', {'lower': True}), {'doc': 'A Commercial and Government Entity (CAGE) code.'}), 11 | ), 12 | 13 | 'forms': ( 14 | ('gov:us:cage', {}, ( 15 | ('name0', ('ou:name', {}), {'doc': 'The name of the organization.'}), 16 | ('name1', ('str', {'lower': True}), {'doc': 'Name Part 1.'}), 17 | ('street', ('str', {'lower': True}), {}), 18 | ('city', ('str', {'lower': True}), {}), 19 | ('state', ('str', {'lower': True}), {}), 20 | ('zip', ('gov:us:zip', {}), {}), 21 | ('cc', ('pol:iso2', {}), {}), 22 | ('country', ('str', {'lower': True}), {}), 23 | ('phone0', ('tel:phone', {}), {}), 24 | ('phone1', ('tel:phone', {}), {}), 25 | )), 26 | 27 | ('gov:us:ssn', {}, []), 28 | ('gov:us:zip', {}, []), 29 | ), 30 | } 31 | name = 'gov:us' 32 | return ((name, modl), ) 33 | -------------------------------------------------------------------------------- /synapse/servers/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/synapse/servers/__init__.py -------------------------------------------------------------------------------- /synapse/servers/aha.py: -------------------------------------------------------------------------------- 1 | # pragma: no cover 2 | import sys 3 | import asyncio 4 | 5 | import synapse.lib.aha as s_aha 6 | 7 | if __name__ == '__main__': # pragma: no cover 8 | asyncio.run(s_aha.AhaCell.execmain(sys.argv[1:])) 9 | -------------------------------------------------------------------------------- /synapse/servers/axon.py: -------------------------------------------------------------------------------- 1 | # pragma: no cover 2 | import sys 3 | import asyncio 4 | 5 | import synapse.axon as s_axon 6 | 7 | if __name__ == '__main__': # pragma: no cover 8 | asyncio.run(s_axon.Axon.execmain(sys.argv[1:])) 9 | -------------------------------------------------------------------------------- /synapse/servers/cell.py: -------------------------------------------------------------------------------- 1 | # pragma: no cover 2 | import sys 3 | import asyncio 4 | 5 | import synapse.exc as s_exc 6 | 7 | import synapse.lib.base as s_base 8 | import synapse.lib.output as s_output 9 | import synapse.lib.dyndeps as s_dyndeps 10 | 11 | async def main(argv, outp=s_output.stdout): 12 | 13 | outp.printf(f'Resolving cellpath: {argv[0]}') 14 | ctor = s_dyndeps.getDynLocal(argv[0]) 15 | if ctor is None: 16 | raise s_exc.NoSuchCtor(name=argv[0], mesg='No Cell ctor found.') 17 | 18 | return await ctor.initFromArgv(argv[1:], outp=outp) 19 | 20 | if __name__ == '__main__': # pragma: no cover 21 | asyncio.run(s_base.main(main(sys.argv[1:]))) 22 | -------------------------------------------------------------------------------- /synapse/servers/cortex.py: -------------------------------------------------------------------------------- 1 | # pragma: no cover 2 | import sys 3 | import asyncio 4 | 5 | import synapse.cortex as s_cortex 6 | 7 | if __name__ == '__main__': # pragma: no cover 8 | asyncio.run(s_cortex.Cortex.execmain(sys.argv[1:])) 9 | -------------------------------------------------------------------------------- /synapse/servers/cryotank.py: -------------------------------------------------------------------------------- 1 | # pragma: no cover 2 | import sys 3 | import asyncio 4 | 5 | import synapse.cryotank as s_cryotank 6 | 7 | if __name__ == '__main__': # pragma: no cover 8 | asyncio.run(s_cryotank.CryoCell.execmain(sys.argv[1:])) 9 | -------------------------------------------------------------------------------- /synapse/servers/jsonstor.py: -------------------------------------------------------------------------------- 1 | # pragma: no cover 2 | import sys 3 | import asyncio 4 | 5 | import synapse.lib.jsonstor as s_jsonstor 6 | 7 | if __name__ == '__main__': # pragma: no cover 8 | asyncio.run(s_jsonstor.JsonStorCell.execmain(sys.argv[1:])) 9 | -------------------------------------------------------------------------------- /synapse/servers/stemcell.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import asyncio 4 | 5 | import synapse.exc as s_exc 6 | import synapse.common as s_common 7 | 8 | import synapse.lib.output as s_output 9 | import synapse.lib.dyndeps as s_dyndeps 10 | 11 | def getStemCell(dirn): 12 | 13 | if not os.path.isdir(dirn): 14 | mesg = f'Directory {dirn} does not exist!' 15 | raise s_exc.NoSuchDir(mesg=mesg) 16 | 17 | ctorname = os.getenv('SYN_STEM_CELL_CTOR') 18 | 19 | cellyaml = os.path.join(dirn, 'cell.yaml') 20 | 21 | if os.path.isfile(cellyaml): 22 | conf = s_common.yamlload(cellyaml) 23 | ctorname = conf.get('cell:ctor', ctorname) 24 | 25 | if ctorname is not None: 26 | ctorname = ctorname.strip() 27 | ctor = s_dyndeps.getDynLocal(ctorname) 28 | if ctor is None: 29 | raise s_exc.NoSuchCtor(mesg=f'Unable to resolve ctor [{ctorname}]', ctor=ctorname) 30 | return ctor 31 | 32 | mesg = f'No such file: {cellyaml} and SYN_STEM_CELL_CTOR environment variable is not set.' 33 | raise s_exc.NoSuchFile(mesg=mesg, path=cellyaml) 34 | 35 | async def main(argv, outp=s_output.stdout): # pragma: no cover 36 | ctor = getStemCell(argv[0]) 37 | return await ctor.execmain(argv, outp=outp) 38 | 39 | if __name__ == '__main__': # pragma: no cover 40 | sys.exit(asyncio.run(main(sys.argv[1:]))) 41 | -------------------------------------------------------------------------------- /synapse/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/synapse/tests/__init__.py -------------------------------------------------------------------------------- /synapse/tests/files/certdir/cas/ca.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICpzCCAY8CBFhUWsEwDQYJKoZIhvcNAQELBQAwDzENMAsGA1UEAwwEdGVzdDAe 3 | Fw0xNjEyMTYyMTIxMDVaFw0yNjEyMTQyMTIxMDVaMA8xDTALBgNVBAMMBHRlc3Qw 4 | ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDG0oXZUQ8JxliQsnALPj0S 5 | ocClzTCJ5E+XEYK2/V5s1XAZXKN318v0Xr6OJxevXIHbBZXnTZSWu2xdSTtQTZQD 6 | VQY259cnXbNF3Ggqvd29w1mHUb8n3063A1SI5UV2nkq0bWPfW7+x3qCNte2ZWalL 7 | Q77uACGAUsU5NPu5MRqtUXrKe0TwUG+13LcDf4fVQnyX/0zzUhKpoly6dir9wLaP 8 | 3HW1dHLjIl0TRbkO9sZInjQYo0b+78nSPXk7SMDlajBtpuzTEmfflw93Do1Lpl/O 9 | /Odhb06iKWVPOG3Rk1nrnnZ6W0gADR+8nzDs99Q0WTHzVH5d73b7K871roP9AYsH 10 | AgMBAAGjEDAOMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAKcDaqp4 11 | imna2QrhhCaTn7hMPdWxOzWj0xCxZgNGzHUHmOq/um3t54bb9R0DcA//F35Xwphv 12 | Vn5s4+zXdZmS1cRvRQMetc0fs35RILD4pD9zXr+kh54MVoKLzS1r1VCk8sSH7zi6 13 | cuJhDeKjndAPW3V1iXG8mupS5EnADhw+lyczGFFR6+su4zIlS8AHN+KkBUsAQ09K 14 | hZhJhX4TX0fo1sX4iyScJv3DT9mlOzHHNpKB+R8rbPmB/FWiyEF6vR+cHkb9H413 15 | MKDpNaomcYMNAmfwPw/bjeD7rtiGE4LEp4a9iHDfoTCxXDu9VNcnWJQs5hmprGex 16 | oNwM0Q91PcsedT0= 17 | -----END CERTIFICATE----- 18 | -------------------------------------------------------------------------------- /synapse/tests/files/certdir/hosts/localhost.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIC3jCCAcYCBFhUWtEwDQYJKoZIhvcNAQELBQAwDzENMAsGA1UEAwwEdGVzdDAe 3 | Fw0xNjEyMTYyMTIxMjFaFw0yNjEyMTQyMTIxMjFaMBQxEjAQBgNVBAMMCWxvY2Fs 4 | aG9zdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKu9QH9Bf+jWYyqu 5 | HG0JsnFBa++SROYffHwoVt394+z5PNULPq6lybjLm/taMXv1CSWrUAoGJH7C8ylI 6 | kajmLDF+5kj5M+wb92Cp1+ml6kcGsqLD9jdgeRFN3MehXT/s8AFFjyLwVRgCol75 7 | XPRkqr6wUU6jhJWDvAkCJzDESi/1+JP8aIWt1pwQPXURTdLxFDb2F/v7CvKXiAKq 8 | vzVIO7/MRw1Q1q+0KDwdBtK/J+/p18CfImiVYzpGw9dxc78NuGNCmUYrXylimtOw 9 | Rwx23f0zHtAgfU29X9RKL2bKX4AqwBMOSkuywUm1uqejcxiII+4h/ilQp2yBhYaR 10 | n3kURT0CAwEAAaNCMEAwEQYJYIZIAYb4QgEBBAQDAgZAMAsGA1UdDwQEAwIFoDAT 11 | BgNVHSUEDDAKBggrBgEFBQcDATAJBgNVHRMEAjAAMA0GCSqGSIb3DQEBCwUAA4IB 12 | AQAshZaFg/Ao4OtBhgLWyxdynHPuw9TNXMSHyPpscKwWt2+RwRwCiLA1wrGR65pQ 13 | ZzPb3FGDuJzwzwGnT5ErP2zlIawX66DgufFl4u2asWA8Rc3g1OhKXBqf9VSAs7KO 14 | LCnLMirQqbYvAdxSQSZyXOgzZMyc2ryPWTiW6UzLJBWNnBd6192nr/JQbfnPKCTy 15 | eSg+iuCc+yRoJFUAHX9R9hNaYk85iuBOA9PIzJAtn5ZumkZvVDq2FM8tTYjxSgAt 16 | YR9BDXtZ+qnU3/Bwhcf6qjI6V6eW+L6cqA7jf5T7MWlJSLcsJTdyzpg1mvDQDqRZ 17 | BxgpQMWvkmnErRikaAMzc33x 18 | -----END CERTIFICATE----- 19 | -------------------------------------------------------------------------------- /synapse/tests/files/certdir/users/user.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIC4zCCAcsCBFhUWtowDQYJKoZIhvcNAQELBQAwDzENMAsGA1UEAwwEdGVzdDAe 3 | Fw0xNjEyMTYyMTIxMzBaFw0yNjEyMTQyMTIxMzBaMBkxFzAVBgNVBAMMDnVzZXJA 4 | bG9jYWxob3N0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxTxbzD7z 5 | PLMqecW88U5NgdzdsH9r8UG0NpmYGth/iAIa3IH9ZU/Xqu8AnhzGKbDRusAWy+PN 6 | jdLhO//5yHye1/U+LDTN/O7LXmWeqzPVTMhKjZCzjQ3losGY5UPou1WtfAONveNE 7 | Eoy+OnKixLVNWdfU6YZcv+RzWZRv1OAIJdnQtCN6xebIvGxpSXPEUFc2QAPOATzd 8 | kwO5NUna8RpZcOY1jsAqXY3VKREZnraqIqGNgG9zRecoi9GZkZ/B8k6eSAffnavW 9 | hwBjABr3ky952nP0usQ1eTiZ+KaPWWeO8ktr5WbecvVbMW0s24rLQqtKz5lt2IB8 10 | RwNv/z5JlaLn0wIDAQABo0IwQDARBglghkgBhvhCAQEEBAMCB4AwCwYDVR0PBAQD 11 | AgeAMBMGA1UdJQQMMAoGCCsGAQUFBwMCMAkGA1UdEwQCMAAwDQYJKoZIhvcNAQEL 12 | BQADggEBAAM4RU0AJB/7UrX+eb5j3Xpk7kQinuX1+/jw3gNT2K5TjjRQIuUuRaRo 13 | nl3oxxG7TlHDPQuDSOkX1w+s8DPEqY4wdC0oC5n+tl8+JRnAcTARKZQFgaH4dnQ6 14 | vy6Bsq+kJg71cr5HscIQUaGeUsJsHpMfQpmt6B2xryx5UhV149vL6/jrlV3uJ9lZ 15 | XB3JT5SI9iKwQ9tlIP+QNAUknGsoTvK3zqa/J9N3lcPMqIYTkzBPoYMlAYnEGj6p 16 | y4+CeLSEMqjRW4of7L3S9xsAg0s5mDBvtVb3Kkl1l+KTvZY1ORBXePgYtV0KKcHI 17 | RqREHhnc+rYBSBc49F8uqNg0yw2Pml8= 18 | -----END CERTIFICATE----- 19 | -------------------------------------------------------------------------------- /synapse/tests/files/changelog/model_2.176.0_16ee721a6b7221344eaf946c3ab4602dda546b1a.yaml.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/synapse/tests/files/changelog/model_2.176.0_16ee721a6b7221344eaf946c3ab4602dda546b1a.yaml.gz -------------------------------------------------------------------------------- /synapse/tests/files/changelog/model_2.176.0_2a25c58bbd344716cd7cbc3f4304d8925b0f4ef2.yaml.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/synapse/tests/files/changelog/model_2.176.0_2a25c58bbd344716cd7cbc3f4304d8925b0f4ef2.yaml.gz -------------------------------------------------------------------------------- /synapse/tests/files/rstorm/httpresp1.json: -------------------------------------------------------------------------------- 1 | { 2 | "code": 200, 3 | "body": { 4 | "data": "1.2.3.4" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /synapse/tests/files/rstorm/httpresp2.json: -------------------------------------------------------------------------------- 1 | { 2 | "code": 200, 3 | "body": "{\"data\": \"5.6.7.8\"}" 4 | } 5 | -------------------------------------------------------------------------------- /synapse/tests/files/rstorm/httpresp3.json: -------------------------------------------------------------------------------- 1 | { 2 | "code": 200, 3 | "body": "notjson" 4 | } 5 | -------------------------------------------------------------------------------- /synapse/tests/files/rstorm/testsvc.py: -------------------------------------------------------------------------------- 1 | import synapse.lib.cell as s_cell 2 | import synapse.lib.stormsvc as s_stormsvc 3 | 4 | class TestsvcApi(s_cell.CellApi, s_stormsvc.StormSvc): 5 | _storm_svc_name = 'testsvc' 6 | _storm_svc_vers = (0, 0, 1) 7 | _storm_svc_pkgs = ( 8 | { 9 | 'name': 'testsvc', 10 | 'version': (0, 0, 1), 11 | 'onload': ''' 12 | $lib.time.sleep($lib.globals.get(onload_sleep, 0)) 13 | $lib.globals.set(testsvc, testsvc-done) 14 | ''', 15 | 'commands': ( 16 | { 17 | 'name': 'testsvc.test', 18 | 'storm': ''' 19 | $lib.print($lib.service.get($cmdconf.svciden).test()) 20 | $lib.print($lib.globals.get(testsvc)) 21 | ''', 22 | }, 23 | ) 24 | }, 25 | ) 26 | 27 | async def test(self): 28 | return await self.cell.test() 29 | 30 | class Testsvc(s_cell.Cell): 31 | 32 | cellapi = TestsvcApi 33 | 34 | confdefs = { 35 | 'secret': {'type': 'string'}, 36 | } 37 | 38 | async def __anit__(self, dirn, conf): 39 | await s_cell.Cell.__anit__(self, dirn, conf=conf) 40 | self.secret = self.conf.req('secret') 41 | 42 | async def test(self): 43 | return self.secret 44 | -------------------------------------------------------------------------------- /synapse/tests/files/stormcov/argvquery.storm: -------------------------------------------------------------------------------- 1 | function foo() { 2 | tee { 3 | if $lib.true { 4 | stop 5 | } 6 | } {} 7 | } 8 | yield $foo() 9 | -------------------------------------------------------------------------------- /synapse/tests/files/stormcov/dupesubs.storm: -------------------------------------------------------------------------------- 1 | $eq = ${ [inet:fqdn=bar.com] } 2 | $eq = ${ [inet:fqdn=bar.com] } 3 | tee { 4 | [inet:fqdn=foo.com] 5 | } { [inet:fqdn=baz.com ] } 6 | $eq 7 | 8 | tee { 9 | [inet:fqdn=argv.com] 10 | } { 11 | [inet:fqdn=argv.com] 12 | } 13 | -------------------------------------------------------------------------------- /synapse/tests/files/stormcov/lookup.storm: -------------------------------------------------------------------------------- 1 | vertex.link | 2 | function foo() { 3 | stop 4 | } 5 | yield $foo() 6 | yield $foo() 7 | -------------------------------------------------------------------------------- /synapse/tests/files/stormcov/pivot.storm: -------------------------------------------------------------------------------- 1 | [inet:fqdn=vertex.link] 2 | -> inet:fqdn 3 | -------------------------------------------------------------------------------- /synapse/tests/files/stormcov/pragma-nocov.storm: -------------------------------------------------------------------------------- 1 | function foo() { 2 | if $lib.true { 3 | stop 4 | } 5 | 6 | if $lib.false { $lib.print("no cover") } // pragma: no cover 7 | 8 | if $lib.false { // pragma: no cover start 9 | $lib.print("multi-line no cover") 10 | } // pragma: no cover stop 11 | 12 | if $lib.false { $lib.print("stop before start") } // pragma: no cover stop 13 | 14 | if $lib.false { // pragma: no cover start 15 | $lib.print("start in a block") // pragma: no cover start 16 | } // pragma: no cover stop 17 | } 18 | yield $foo() 19 | -------------------------------------------------------------------------------- /synapse/tests/files/stormcov/spin.storm: -------------------------------------------------------------------------------- 1 | 2 | [inet:fqdn=vertex.link] 3 | spin 4 | -------------------------------------------------------------------------------- /synapse/tests/files/stormcov/stormctrl.storm: -------------------------------------------------------------------------------- 1 | function foo() { 2 | if $lib.true { 3 | stop 4 | } 5 | } 6 | yield $foo() 7 | -------------------------------------------------------------------------------- /synapse/tests/files/stormmod/common: -------------------------------------------------------------------------------- 1 | inet:fqdn 2 | -------------------------------------------------------------------------------- /synapse/tests/files/stormpkg/badapidef.yaml: -------------------------------------------------------------------------------- 1 | name: testpkg 2 | version: 0.0.1 3 | 4 | modules: 5 | - name: apimod 6 | apidefs: 7 | - name: status 8 | desc: Get the status of the foo. 9 | type: 10 | type: function 11 | returns: 12 | type: 42 13 | desc: A status dictionary. 14 | -------------------------------------------------------------------------------- /synapse/tests/files/stormpkg/badcmdname.yaml: -------------------------------------------------------------------------------- 1 | name: badcmdname 2 | version: [0, 0, 1] 3 | 4 | commands: 5 | - name: invalidCMD 6 | descr: No capital letters in command names! 7 | -------------------------------------------------------------------------------- /synapse/tests/files/stormpkg/badendpoints.yaml: -------------------------------------------------------------------------------- 1 | name: test 2 | version: 0.0.1 3 | commands: 4 | - name: 'foo.bar' 5 | storm: (null) 6 | endpoints: 7 | - host: vertex.link 8 | -------------------------------------------------------------------------------- /synapse/tests/files/stormpkg/badjsonpkg.yaml: -------------------------------------------------------------------------------- 1 | name: badjsonpkg 2 | version: 0.0.1 3 | 4 | modules: 5 | - name: testmod 6 | modconf: 7 | test: valu 8 | 1234: newp 9 | -------------------------------------------------------------------------------- /synapse/tests/files/stormpkg/docs/foobar.md: -------------------------------------------------------------------------------- 1 | Hello! 2 | -------------------------------------------------------------------------------- /synapse/tests/files/stormpkg/docs/foobar.svg: -------------------------------------------------------------------------------- 1 | stuff 2 | -------------------------------------------------------------------------------- /synapse/tests/files/stormpkg/dotstorm/dotstorm.yaml: -------------------------------------------------------------------------------- 1 | name: dotstorm 2 | version: 0.0.1 3 | 4 | genopts: 5 | dotstorm: true 6 | 7 | modules: 8 | - name: dotstorm.foo 9 | 10 | commands: 11 | - name: dotstorm.bar 12 | 13 | onload: | 14 | $lib.time.sleep(0) 15 | -------------------------------------------------------------------------------- /synapse/tests/files/stormpkg/dotstorm/storm/commands/dotstorm.bar.storm: -------------------------------------------------------------------------------- 1 | $lib.print("hello bar") 2 | -------------------------------------------------------------------------------- /synapse/tests/files/stormpkg/dotstorm/storm/modules/dotstorm.foo.storm: -------------------------------------------------------------------------------- 1 | $lib.print("hello foo") 2 | -------------------------------------------------------------------------------- /synapse/tests/files/stormpkg/nocontent.yaml: -------------------------------------------------------------------------------- 1 | name: testpkg 2 | version: 0.0.1 3 | 4 | docs: 5 | - title: Foo Bar 6 | -------------------------------------------------------------------------------- /synapse/tests/files/stormpkg/nomime.yaml: -------------------------------------------------------------------------------- 1 | name: testpkg 2 | version: 0.0.1 3 | 4 | logo: 5 | file: c3R1ZmYK 6 | -------------------------------------------------------------------------------- /synapse/tests/files/stormpkg/nopath.yaml: -------------------------------------------------------------------------------- 1 | name: testpkg 2 | version: 0.0.1 3 | 4 | logo: 5 | mime: image/svg 6 | -------------------------------------------------------------------------------- /synapse/tests/files/stormpkg/nosuchfile.yaml: -------------------------------------------------------------------------------- 1 | name: testpkg 2 | version: 0.0.1 3 | 4 | docs: 5 | - title: newp 6 | path: docs/newp.md 7 | -------------------------------------------------------------------------------- /synapse/tests/files/stormpkg/notitle.yaml: -------------------------------------------------------------------------------- 1 | name: testpkg 2 | version: 0.0.1 3 | 4 | docs: 5 | - path: docs/foobar.md 6 | -------------------------------------------------------------------------------- /synapse/tests/files/stormpkg/optic/index.html: -------------------------------------------------------------------------------- 1 | hi 2 | -------------------------------------------------------------------------------- /synapse/tests/files/stormpkg/storm/commands/invalidCMD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/synapse/tests/files/stormpkg/storm/commands/invalidCMD -------------------------------------------------------------------------------- /synapse/tests/files/stormpkg/storm/commands/testpkg.baz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/synapse/tests/files/stormpkg/storm/commands/testpkg.baz -------------------------------------------------------------------------------- /synapse/tests/files/stormpkg/storm/commands/testpkgcmd: -------------------------------------------------------------------------------- 1 | inet:ipv6 2 | -------------------------------------------------------------------------------- /synapse/tests/files/stormpkg/storm/modules/apimod: -------------------------------------------------------------------------------- 1 | 2 | function search(text, mintime="-30days") { 3 | for $t in $text { 4 | [ it:devstr=$t ] 5 | } 6 | } 7 | 8 | function status() { 9 | return(({"ok": true})) 10 | } 11 | -------------------------------------------------------------------------------- /synapse/tests/files/stormpkg/storm/modules/testmod: -------------------------------------------------------------------------------- 1 | inet:ipv4 2 | -------------------------------------------------------------------------------- /synapse/tests/files/stormpkg/workflows/testpkg-bam.newp: -------------------------------------------------------------------------------- 1 | name: newp 2 | desc: not included 3 | -------------------------------------------------------------------------------- /synapse/tests/files/stormpkg/workflows/testpkg-baz.yaml: -------------------------------------------------------------------------------- 1 | name: real-baz 2 | desc: this is the real baz desc 3 | -------------------------------------------------------------------------------- /synapse/tests/files/stormpkg/workflows/testpkg-foo.yaml: -------------------------------------------------------------------------------- 1 | name: foo 2 | desc: a foo workflow 3 | -------------------------------------------------------------------------------- /synapse/tests/files/test.dat: -------------------------------------------------------------------------------- 1 | woot 2 | -------------------------------------------------------------------------------- /synapse/tests/files/testcore/cell.yaml: -------------------------------------------------------------------------------- 1 | modules: 2 | - synapse.tests.utils.TestModule 3 | -------------------------------------------------------------------------------- /synapse/tests/nopmod.py: -------------------------------------------------------------------------------- 1 | ''' 2 | A python module used for testing dmon dynamic module loading. 3 | ''' 4 | -------------------------------------------------------------------------------- /synapse/tests/test_data.py: -------------------------------------------------------------------------------- 1 | import synapse.tests.utils as s_t_utils 2 | 3 | import synapse.data as s_data 4 | 5 | class DataTest(s_t_utils.SynTest): 6 | 7 | def test_data_iana_tlds(self): 8 | self.true('link' in s_data.get('iana.tlds')) 9 | -------------------------------------------------------------------------------- /synapse/tests/test_glob.py: -------------------------------------------------------------------------------- 1 | import synapse.glob as s_glob 2 | 3 | import synapse.tests.utils as s_t_utils 4 | 5 | class GlobTest(s_t_utils.SynTest): 6 | 7 | def test_glob_sync(self): 8 | 9 | async def afoo(): 10 | return 42 11 | 12 | retn = s_glob.sync(afoo()) 13 | self.eq(retn, 42) 14 | -------------------------------------------------------------------------------- /synapse/tests/test_init.py: -------------------------------------------------------------------------------- 1 | 2 | import synapse.tests.utils as s_t_utils 3 | 4 | class InitTest(s_t_utils.SynTest): 5 | pass 6 | 7 | ''' 8 | def test_init_modules(self): 9 | os.environ['SYN_MODULES'] = 'fakenotrealmod , badnothere,math' 10 | msg = 'SYN_MODULES failed: badnothere (NoSuchDyn: name=\'badnothere\')' 11 | with self.getLoggerStream('synapse', msg) as stream: 12 | imp.reload(synapse) 13 | self.true(stream.wait(10)) 14 | 15 | stream.seek(0) 16 | self.isin(msg, stream.read()) 17 | self.isin(('math', 2.0, None), synapse.lib.modules.call('sqrt', 4)) 18 | ''' 19 | -------------------------------------------------------------------------------- /synapse/tests/test_lib_const.py: -------------------------------------------------------------------------------- 1 | import synapse.tests.utils as s_t_utils 2 | 3 | import synapse.lib.const as s_const 4 | 5 | class ConstTest(s_t_utils.SynTest): 6 | def test_const_kilos(self): 7 | self.eq(s_const.kilobyte, 10 ** 3) 8 | self.eq(s_const.megabyte, 10 ** 6) 9 | self.eq(s_const.gigabyte, 10 ** 9) 10 | self.eq(s_const.terabyte, 10 ** 12) 11 | self.eq(s_const.petabyte, 10 ** 15) 12 | self.eq(s_const.exabyte, 10 ** 18) 13 | self.eq(s_const.zettabyte, 10 ** 21) 14 | self.eq(s_const.yottabyte, 10 ** 24) 15 | 16 | def test_const_kibis(self): 17 | self.eq(s_const.kibibyte, 2 ** 10) 18 | self.eq(s_const.mebibyte, 2 ** 20) 19 | self.eq(s_const.gibibyte, 2 ** 30) 20 | self.eq(s_const.tebibyte, 2 ** 40) 21 | self.eq(s_const.pebibyte, 2 ** 50) 22 | self.eq(s_const.exbibyte, 2 ** 60) 23 | self.eq(s_const.zebibyte, 2 ** 70) 24 | self.eq(s_const.yobibyte, 2 ** 80) 25 | -------------------------------------------------------------------------------- /synapse/tests/test_lib_crypto_coin.py: -------------------------------------------------------------------------------- 1 | import regex 2 | 3 | import synapse.common as s_common 4 | import synapse.lib.crypto.coin as s_coin 5 | 6 | import synapse.tests.utils as s_t_utils 7 | 8 | class CryptoCoinTest(s_t_utils.SynTest): 9 | def test_eip55(self): 10 | # Test bad input on eip55 11 | v = s_common.guid() + 'X' 12 | self.none(s_coin.ether_eip55(v)) 13 | 14 | valu = regex.search(r'(?P[a-z]+)', 'foobar') 15 | self.eq(s_coin.eth_check(valu), (None, {})) 16 | -------------------------------------------------------------------------------- /synapse/tests/test_lib_datfile.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | import synapse 4 | import synapse.lib.datfile as s_datfile 5 | 6 | import synapse.tests.utils as s_t_utils 7 | 8 | syndir = os.path.dirname(synapse.__file__) 9 | 10 | class DatFileTest(s_t_utils.SynTest): 11 | 12 | def test_datfile_basic(self): 13 | with s_datfile.openDatFile('synapse.tests/files/test.dat') as fd: 14 | self.nn(fd) 15 | self.eq(fd.read(), b'woot\n') 16 | -------------------------------------------------------------------------------- /synapse/tests/test_lib_dyndeps.py: -------------------------------------------------------------------------------- 1 | import synapse.exc as s_exc 2 | import synapse.lib.dyndeps as s_dyndeps 3 | import synapse.tests.utils as s_t_utils 4 | 5 | hehe = 'woot' 6 | 7 | class Foo: 8 | def bar(self): 9 | return 'baz' 10 | 11 | def woot(x, y=30): 12 | return x + y 13 | 14 | class DynDepsTest(s_t_utils.SynTest): 15 | 16 | def test_dyndeps_dynmod(self): 17 | with self.getLoggerStream('synapse.lib.dyndeps', 'Failed to import "- -"') as stream: 18 | self.none(s_dyndeps.getDynMod('- -')) 19 | self.true(stream.wait(1)) 20 | self.nn(s_dyndeps.getDynMod('sys')) 21 | 22 | def test_dyndeps_dynloc(self): 23 | self.none(s_dyndeps.getDynLocal('synapse.tests.test_lib_dyndeps.gronk')) 24 | self.nn(s_dyndeps.getDynLocal('synapse.tests.test_lib_dyndeps.hehe')) 25 | 26 | def test_dyndeps_dyntask(self): 27 | task = ('synapse.tests.test_lib_dyndeps.Foo', (), {}) 28 | foo = s_dyndeps.runDynTask(task) 29 | self.eq(foo.bar(), 'baz') 30 | 31 | def test_dyndeps_nosuchdyn(self): 32 | self.raises(s_exc.NoSuchDyn, s_dyndeps.tryDynMod, 'newpnewp') 33 | self.raises(s_exc.NoSuchDyn, s_dyndeps.tryDynLocal, 'sys.newpnewp') 34 | 35 | def test_dyndeps_meth(self): 36 | self.nn(s_dyndeps.getDynMeth('synapse.lib.base.Base.fini')) 37 | self.none(s_dyndeps.getDynMeth('synapse.lib.base.Base.newp')) 38 | -------------------------------------------------------------------------------- /synapse/tests/test_lib_hashitem.py: -------------------------------------------------------------------------------- 1 | import synapse.tests.utils as s_t_utils 2 | 3 | import synapse.lib.hashitem as s_hashitem 4 | 5 | class HashItemTest(s_t_utils.SynTest): 6 | 7 | def test_lib_hashitem(self): 8 | x = { 9 | 'foo': ['bar', 'baz'], 10 | 'boing': ('gniob', 'boing'), 11 | 12 | 'lol': 10, 13 | 'hehe': 'haha', 14 | 'gronk': { 15 | 'hurr': 30, 16 | 'durr': 40, 17 | }, 18 | } 19 | 20 | y = { 21 | 'boing': ('gniob', 'boing'), 22 | 'foo': ['bar', 'baz'], 23 | 24 | 'lol': 10, 25 | 'gronk': { 26 | 'durr': 40, 27 | 'hurr': 30, 28 | }, 29 | 'hehe': 'haha', 30 | } 31 | 32 | self.eq(s_hashitem.hashitem(x), s_hashitem.hashitem(y)) 33 | -------------------------------------------------------------------------------- /synapse/tests/test_lib_interval.py: -------------------------------------------------------------------------------- 1 | import synapse.tests.utils as s_t_utils 2 | 3 | import synapse.lib.interval as s_interval 4 | 5 | class IvalTest(s_t_utils.SynTest): 6 | 7 | def test_ival_fold(self): 8 | vals = [None, 100, 20, None] 9 | self.eq(s_interval.fold(*vals), (20, 100)) 10 | self.none(s_interval.fold()) 11 | 12 | def test_ival_overlap(self): 13 | 14 | ival0 = s_interval.fold(10, 20) 15 | ival1 = s_interval.fold(15, 30) 16 | ival2 = s_interval.fold(30, 50) 17 | ival3 = s_interval.fold(1, 100) 18 | 19 | self.true(s_interval.overlap(ival0, ival1)) 20 | self.false(s_interval.overlap(ival1, ival2)) 21 | 22 | self.true(s_interval.overlap(ival0, ival3)) 23 | self.true(s_interval.overlap(ival1, ival3)) 24 | self.true(s_interval.overlap(ival2, ival3)) 25 | 26 | def test_ival_parsetime(self): 27 | self.eq(s_interval.parsetime('1970-1980'), (0, 315532800000)) 28 | -------------------------------------------------------------------------------- /synapse/tests/test_lib_output.py: -------------------------------------------------------------------------------- 1 | import synapse.tests.utils as s_t_utils 2 | 3 | import synapse.lib.output as s_output 4 | 5 | class TestOutPut(s_t_utils.SynTest): 6 | 7 | # def test_output(self): 8 | # outp = s_output.OutPut() 9 | # outp.printf('foo') 10 | # outp.printf('bar') 11 | 12 | def test_output_bytes(self): 13 | outp = s_output.OutPutBytes() 14 | 15 | outp.printf('foo') 16 | outp.printf('bar') 17 | 18 | outp.fd.seek(0) 19 | self.eq(outp.fd.read(), b'foo\nbar\n') 20 | 21 | def test_output_str(self): 22 | outp = s_output.OutPutStr() 23 | outp.printf('foo') 24 | outp.printf('bar') 25 | 26 | self.eq(str(outp), 'foo\nbar\n') 27 | -------------------------------------------------------------------------------- /synapse/tests/test_lib_queue.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | import synapse.lib.queue as s_queue 4 | 5 | import synapse.tests.utils as s_t_utils 6 | 7 | class QueueTest(s_t_utils.SynTest): 8 | 9 | async def test_queue_aqueue(self): 10 | 11 | queue = await s_queue.AQueue.anit() 12 | queue.put('foo') 13 | 14 | async def poke(): 15 | queue.put('bar') 16 | 17 | self.eq(['foo'], await queue.slice()) 18 | 19 | queue.schedCoro(poke()) 20 | 21 | self.eq(['bar'], await queue.slice()) 22 | 23 | async def test_queue_window(self): 24 | 25 | wind = await s_queue.Window.anit(maxsize=3) 26 | 27 | self.true(await wind.put('asdf')) 28 | self.false(wind.isfini) 29 | 30 | self.true(await wind.puts(('hehe', 'haha'))) 31 | 32 | self.true(wind.isfini) 33 | 34 | self.false(await wind.put('asdf')) 35 | self.false(await wind.puts(('hehe', 'haha'))) 36 | 37 | self.eq(('asdf', 'hehe', 'haha'), [x async for x in wind]) 38 | -------------------------------------------------------------------------------- /synapse/tests/test_lib_ratelimit.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | import synapse.lib.ratelimit as s_ratelimit 4 | 5 | import synapse.tests.utils as s_t_utils 6 | 7 | class RateLimitTest(s_t_utils.SynTest): 8 | 9 | def test_ratelimit_allow(self): 10 | rlim = s_ratelimit.RateLimit(3, 0.2) 11 | 12 | self.true(rlim.allows()) 13 | self.true(rlim.allows()) 14 | self.true(rlim.allows()) 15 | 16 | self.false(rlim.allows()) 17 | 18 | time.sleep(0.1) 19 | 20 | self.true(rlim.allows()) 21 | -------------------------------------------------------------------------------- /synapse/tests/test_lib_slaboffs.py: -------------------------------------------------------------------------------- 1 | import os 2 | import synapse.common as s_common 3 | 4 | import synapse.lib.lmdbslab as s_lmdbslab 5 | import synapse.lib.slaboffs as s_slaboffs 6 | 7 | import synapse.tests.utils as s_t_utils 8 | 9 | class SlabOffsTest(s_t_utils.SynTest): 10 | 11 | async def test_lmdbslab_base(self): 12 | 13 | with self.getTestDir() as dirn: 14 | 15 | path = os.path.join(dirn, 'test.lmdb') 16 | async with await s_lmdbslab.Slab.anit(path) as slab: 17 | 18 | offsdb = slab.initdb('offsets') 19 | offs = s_slaboffs.SlabOffs(slab, offsdb) 20 | 21 | guid = s_common.guid() 22 | self.eq(0, offs.get(guid)) 23 | 24 | offs.set(guid, 42) 25 | self.eq(42, offs.get(guid)) 26 | 27 | offs.delete(guid) 28 | self.eq(0, offs.get(guid)) 29 | -------------------------------------------------------------------------------- /synapse/tests/test_lib_storm_format.py: -------------------------------------------------------------------------------- 1 | import synapse.lib.storm_format as s_storm_format 2 | import synapse.lib.parser as s_parser 3 | 4 | from synapse.tests.test_lib_grammar import Queries 5 | 6 | def test_highlight_storm(): 7 | 8 | for _, query in enumerate(Queries): 9 | s_storm_format.highlight_storm(s_parser.LarkParser, query) 10 | -------------------------------------------------------------------------------- /synapse/tests/test_lib_stormlib_env.py: -------------------------------------------------------------------------------- 1 | import os 2 | import synapse.exc as s_exc 3 | import synapse.tests.utils as s_test 4 | 5 | class StormLibEnvTest(s_test.SynTest): 6 | 7 | async def test_stormlib_env(self): 8 | 9 | with self.setTstEnvars(SYN_STORM_ENV_WOOT='woot'): 10 | 11 | async with self.getTestCore() as core: 12 | 13 | self.eq('woot', await core.callStorm('return($lib.env.get(SYN_STORM_ENV_WOOT))')) 14 | self.eq('hehe', await core.callStorm('return($lib.env.get(SYN_STORM_ENV_HEHE, default=hehe))')) 15 | 16 | self.none(await core.callStorm('return($lib.env.get(SYN_STORM_ENV_HEHE))')) 17 | 18 | visi = await core.auth.addUser('visi') 19 | 20 | with self.raises(s_exc.AuthDeny): 21 | opts = {'user': visi.iden} 22 | await core.callStorm('return($lib.env.get(SYN_STORM_ENV_WOOT))', opts=opts) 23 | 24 | with self.raises(s_exc.BadArg): 25 | await core.callStorm('return($lib.env.get(USER))') 26 | -------------------------------------------------------------------------------- /synapse/tests/test_lib_stormlib_ethereum.py: -------------------------------------------------------------------------------- 1 | import synapse.tests.utils as s_test 2 | 3 | class EthereumTest(s_test.SynTest): 4 | 5 | async def test_storm_ethereum(self): 6 | 7 | async with self.getTestCore() as core: 8 | 9 | addr = '0x0f0186fd42B545DcEAA0732fF40c4c0DCb8EE421' 10 | 11 | retn = await core.callStorm(f'return($lib.crypto.coin.ethereum.eip55({addr}))') 12 | self.eq(retn, (True, addr)) 13 | 14 | laddr = addr.lower() 15 | retn = await core.callStorm(f'return($lib.crypto.coin.ethereum.eip55({laddr}))') 16 | self.eq(retn, (True, addr)) 17 | 18 | retn = await core.callStorm(f'return($lib.crypto.coin.ethereum.eip55(foo))') 19 | self.eq(retn, (False, None)) 20 | 21 | retn = await core.callStorm(f'return($lib.crypto.coin.ethereum.eip55($lib.null))') 22 | self.eq(retn, (False, None)) 23 | -------------------------------------------------------------------------------- /synapse/tests/test_lib_stormlib_gis.py: -------------------------------------------------------------------------------- 1 | import synapse.exc as s_exc 2 | 3 | import synapse.tests.utils as s_test 4 | 5 | class StormLibGisTest(s_test.SynTest): 6 | 7 | async def test_stormlib_gis_bbox(self): 8 | 9 | async with self.getTestCore() as core: 10 | 11 | lbox = await core.callStorm('return($lib.gis.bbox(-2.0783, 51.8994, $lib.cast(geo:dist, 1km)))') 12 | self.eq(lbox, (-2.0928746526154747, 13 | -2.0637253473845254, 14 | 51.890406796362754, 15 | 51.908393203637246)) 16 | 17 | with self.raises(s_exc.BadArg): 18 | lbox = await core.callStorm('return($lib.gis.bbox(newp, -2.0783, 1))') 19 | 20 | with self.raises(s_exc.BadArg): 21 | lbox = await core.callStorm('return($lib.gis.bbox(51.2, -2.0783, newp))') 22 | -------------------------------------------------------------------------------- /synapse/tests/test_lib_stormlib_ipv6.py: -------------------------------------------------------------------------------- 1 | import synapse.exc as s_exc 2 | 3 | import synapse.tests.utils as s_test 4 | 5 | class StormIpv6Test(s_test.SynTest): 6 | 7 | async def test_storm_ipv6(self): 8 | async with self.getTestCore() as core: 9 | 10 | self.len(1, await core.nodes('[inet:ipv6=2001:4860:4860::8888]')) 11 | query = 'inet:ipv6=2001:4860:4860::8888 return ( $lib.inet.ipv6.expand($node.value()) )' 12 | self.eq('2001:4860:4860:0000:0000:0000:0000:8888', 13 | await core.callStorm(query)) 14 | 15 | query = '$valu="2001:4860:4860::8888 " return ( $lib.inet.ipv6.expand($valu) )' 16 | self.eq('2001:4860:4860:0000:0000:0000:0000:8888', 17 | await core.callStorm(query)) 18 | 19 | query = '$valu="2001:4860:4860::XXXX" return ( $lib.inet.ipv6.expand($valu) )' 20 | with self.raises(s_exc.StormRuntimeError): 21 | await core.callStorm(query) 22 | -------------------------------------------------------------------------------- /synapse/tests/test_lib_stormlib_utils.py: -------------------------------------------------------------------------------- 1 | import synapse.exc as s_exc 2 | import synapse.tests.utils as s_test 3 | 4 | class UtilsTest(s_test.SynTest): 5 | 6 | async def test_lib_stormlib_utils_todo(self): 7 | 8 | async with self.getTestCore() as core: 9 | 10 | valu = await core.callStorm('return($lib.utils.todo(foo))') 11 | self.eq(valu, ('foo', (), {})) 12 | 13 | valu = await core.callStorm('return($lib.utils.todo(fooName, arg1, arg2, keyword=bar, anotherkeyword=hehe))') 14 | self.eq(valu, ('fooName', ('arg1', 'arg2'), {'keyword': 'bar', 'anotherkeyword': 'hehe'})) 15 | -------------------------------------------------------------------------------- /synapse/tests/test_lib_thishost.py: -------------------------------------------------------------------------------- 1 | import synapse.tests.utils as s_t_utils 2 | 3 | import synapse.lib.thishost as s_thishost 4 | 5 | class ThisTest(s_t_utils.SynTest): 6 | 7 | def test_thishost_hostname(self): 8 | self.nn(s_thishost.get('hostname')) 9 | 10 | def test_thishost_ptrsize(self): 11 | self.nn(s_thishost.get('ptrsize')) 12 | 13 | def test_thishost_platform(self): 14 | self.nn(s_thishost.get('platform')) 15 | -------------------------------------------------------------------------------- /synapse/tests/test_lookup_iso3166.py: -------------------------------------------------------------------------------- 1 | import synapse.tests.utils as s_t_utils 2 | 3 | import synapse.lookup.iso3166 as s_l_country 4 | 5 | 6 | class CountryLookTest(s_t_utils.SynTest): 7 | 8 | def test_lookup_countries(self): 9 | self.eq(s_l_country.country2iso.get('united states of america'), 'us') 10 | self.eq(s_l_country.country2iso.get('mexico'), 'mx') 11 | self.eq(s_l_country.country2iso.get('vertexLandia'), None) 12 | -------------------------------------------------------------------------------- /synapse/tests/test_lookup_phonenum.py: -------------------------------------------------------------------------------- 1 | import synapse.tests.utils as s_t_utils 2 | 3 | import synapse.lookup.phonenum as s_l_phone 4 | 5 | class PhLookTest(s_t_utils.SynTest): 6 | 7 | def test_lookup_phonenum(self): 8 | self.eq(s_l_phone.getPhoneInfo(18075551212)['cc'], 'ca') 9 | self.eq(s_l_phone.getPhoneInfo(17035551212)['cc'], 'us') 10 | -------------------------------------------------------------------------------- /synapse/tests/test_mindmeld.py: -------------------------------------------------------------------------------- 1 | # reserved for future use 2 | -------------------------------------------------------------------------------- /synapse/tests/test_model_entity.py: -------------------------------------------------------------------------------- 1 | import synapse.tests.utils as s_test 2 | 3 | class EntityModelTest(s_test.SynTest): 4 | 5 | async def test_entity_relationship(self): 6 | 7 | async with self.getTestCore() as core: 8 | 9 | nodes = await core.nodes('''[ 10 | entity:relationship=* 11 | :type=tasks 12 | :period=(2022, ?) 13 | :source={[ ou:org=({"name": "China Ministry of State Security (MSS)"}) ]} 14 | :target={[ risk:threat=({"org:name": "APT34", "reporter:name": "vertex"}) ]} 15 | ]''') 16 | 17 | self.len(1, nodes) 18 | self.eq(nodes[0].get('type'), 'tasks.') 19 | self.eq(nodes[0].get('period'), (1640995200000, 9223372036854775807)) 20 | self.eq(nodes[0].get('source'), ('ou:org', '3332a704ed21dc3274d5731acc54a0ee')) 21 | self.eq(nodes[0].get('target'), ('risk:threat', 'e15738ebae52273300b51c08eaad3a36')) 22 | -------------------------------------------------------------------------------- /synapse/tests/test_model_gov_cn.py: -------------------------------------------------------------------------------- 1 | import synapse.common as s_common 2 | import synapse.tests.utils as s_t_utils 3 | 4 | class CnGovTest(s_t_utils.SynTest): 5 | 6 | async def test_models_cngov_mucd(self): 7 | 8 | async with self.getTestCore() as core: 9 | org0 = s_common.guid() 10 | nodes = await core.nodes('[gov:cn:icp=12345678 :org=$org]', opts={'vars': {'org': org0}}) 11 | self.len(1, nodes) 12 | node = nodes[0] 13 | self.eq(node.ndef, ('gov:cn:icp', 12345678)) 14 | self.eq(node.get('org'), org0) 15 | 16 | nodes = await core.nodes('[gov:cn:mucd=61786]') 17 | self.len(1, nodes) 18 | node = nodes[0] 19 | self.eq(node.ndef, ('gov:cn:mucd', 61786)) 20 | -------------------------------------------------------------------------------- /synapse/tests/test_model_gov_intl.py: -------------------------------------------------------------------------------- 1 | import synapse.tests.utils as s_t_utils 2 | 3 | class IntlGovTest(s_t_utils.SynTest): 4 | 5 | async def test_models_intl(self): 6 | 7 | async with self.getTestCore() as core: 8 | q = 'return( $lib.trycast(gov:intl:un:m49, $valu) )' 9 | 10 | isok, valu = await core.callStorm(q, opts={'vars': {'valu': 1}}) 11 | self.true(isok) 12 | self.eq(valu, 1) 13 | 14 | isok, valu = await core.callStorm(q, opts={'vars': {'valu': 0}}) 15 | self.false(isok) 16 | self.none(valu) 17 | 18 | isok, valu = await core.callStorm(q, opts={'vars': {'valu': '999'}}) 19 | self.true(isok) 20 | self.eq(valu, 999) 21 | 22 | isok, valu = await core.callStorm(q, opts={'vars': {'valu': 1000}}) 23 | self.false(isok) 24 | self.none(valu) 25 | -------------------------------------------------------------------------------- /synapse/tests/test_model_math.py: -------------------------------------------------------------------------------- 1 | import synapse.common as s_common 2 | import synapse.tests.utils as s_t_utils 3 | 4 | class MathTest(s_t_utils.SynTest): 5 | 6 | async def test_model_math_algo(self): 7 | 8 | async with self.getTestCore() as core: 9 | nodes = await core.nodes(''' 10 | [ math:algorithm=* 11 | :name=" ImPHaSH " 12 | :created=20120202 13 | :type=hash.imports 14 | :desc="Import Hashes!" 15 | ] 16 | ''') 17 | self.len(1, nodes) 18 | self.eq('imphash', nodes[0].get('name')) 19 | self.eq('hash.imports.', nodes[0].get('type')) 20 | self.eq(1328140800000, nodes[0].get('created')) 21 | self.eq("Import Hashes!", nodes[0].get('desc')) 22 | self.len(1, await core.nodes('math:algorithm -> math:algorithm:type:taxonomy')) 23 | -------------------------------------------------------------------------------- /synapse/tests/test_servers_axon.py: -------------------------------------------------------------------------------- 1 | import hashlib 2 | 3 | import synapse.axon as s_axon 4 | 5 | import synapse.tests.utils as s_t_utils 6 | 7 | asdfhash = hashlib.sha256(b'asdfasdf').digest() 8 | 9 | class AxonServerTest(s_t_utils.SynTest): 10 | 11 | async def test_server(self): 12 | 13 | with self.getTestDir() as dirn: 14 | async with self.withSetLoggingMock() as mock: 15 | 16 | argv = [dirn, 17 | '--telepath', 'tcp://127.0.0.1:0/', 18 | '--https', '0', 19 | '--name', 'teleaxon'] 20 | 21 | async with await s_axon.Axon.initFromArgv(argv,) as axon: 22 | async with axon.getLocalProxy() as proxy: 23 | async with await proxy.upload() as fd: 24 | await fd.write(b'asdfasdf') 25 | await fd.save() 26 | 27 | self.true(axon.dmon.shared.get('teleaxon') is axon) 28 | 29 | # And data persists... 30 | async with await s_axon.Axon.initFromArgv(argv,) as axon: 31 | async with axon.getLocalProxy() as proxy: 32 | self.true(await proxy.has(asdfhash)) 33 | -------------------------------------------------------------------------------- /synapse/tests/test_servers_cortex.py: -------------------------------------------------------------------------------- 1 | import synapse.common as s_common 2 | import synapse.cortex as s_cortex 3 | import synapse.telepath as s_telepath 4 | 5 | import synapse.tests.utils as s_t_utils 6 | 7 | class CortexServerTest(s_t_utils.SynTest): 8 | 9 | async def test_server(self): 10 | with self.getTestDir() as dirn: 11 | async with self.withSetLoggingMock() as mock: 12 | guid = s_common.guid() 13 | 14 | argv = [dirn, 15 | '--telepath', 'tcp://127.0.0.1:0/', 16 | '--https', '0', 17 | '--name', 'telecore'] 18 | async with await s_cortex.Cortex.initFromArgv(argv) as core: 19 | 20 | async with await s_telepath.openurl(f'cell://{dirn}') as proxy: 21 | # Make a node with the cortex 22 | self.eq(1, await proxy.count(f'[ou:org={guid}]')) 23 | 24 | self.true(core.dmon.shared.get('*') is core) 25 | self.true(core.dmon.shared.get('cortex') is core) 26 | self.true(core.dmon.shared.get('telecore') is core) 27 | 28 | # And data persists... 29 | async with await s_cortex.Cortex.initFromArgv(argv) as core: 30 | async with await s_telepath.openurl(f'cell://{dirn}') as proxy: 31 | self.eq(1, await proxy.count(f'ou:org={guid}')) 32 | 33 | self.eq(2, mock.call_count) 34 | -------------------------------------------------------------------------------- /synapse/tests/test_servers_cryotank.py: -------------------------------------------------------------------------------- 1 | import synapse.cryotank as s_cryo 2 | 3 | import synapse.tests.utils as s_t_utils 4 | 5 | class CryoServerTest(s_t_utils.SynTest): 6 | 7 | async def test_server(self): 8 | 9 | recs = ( 10 | ('hehe', {'haha': 1}), 11 | ('woah', {'dude': 1}), 12 | ) 13 | 14 | with self.getTestDir() as dirn: 15 | async with self.withSetLoggingMock() as mock: 16 | 17 | argv = [dirn, 18 | '--telepath', 'tcp://127.0.0.1:0/', 19 | '--https', '0', 20 | '--name', 'telecryo'] 21 | 22 | async with await s_cryo.CryoCell.initFromArgv(argv) as cryotank: 23 | async with cryotank.getLocalProxy() as proxy: 24 | await proxy.puts('foo', recs) 25 | 26 | self.true(cryotank.dmon.shared.get('telecryo') is cryotank) 27 | 28 | # And data persists... 29 | async with await s_cryo.CryoCell.initFromArgv(argv) as telecryo: 30 | async with telecryo.getLocalProxy() as proxy: 31 | precs = await s_t_utils.alist(proxy.slice('foo', 0, 100)) 32 | precs = [rec for offset, rec in precs] 33 | self.eq(precs, recs) 34 | -------------------------------------------------------------------------------- /synapse/tests/test_tools_axon2axon.py: -------------------------------------------------------------------------------- 1 | import synapse.tests.utils as s_test 2 | import synapse.tools.axon2axon as s_axon2axon 3 | 4 | class Axon2AxonTest(s_test.SynTest): 5 | 6 | async def test_axon2axon(self): 7 | 8 | async with self.getTestAxon() as srcaxon: 9 | 10 | async with self.getTestAxon() as dstaxon: 11 | 12 | srcurl = srcaxon.getLocalUrl() 13 | dsturl = dstaxon.getLocalUrl() 14 | 15 | (size, sha256) = await srcaxon.put(b'visi') 16 | 17 | outp = self.getTestOutp() 18 | await s_axon2axon.main([srcurl, dsturl], outp=outp) 19 | self.true(await dstaxon.has(sha256)) 20 | outp.expect('Starting transfer at offset: 0') 21 | outp.expect('[ 0] - e45bbb7e03acacf4d1cca4c16af1ec0c51d777d10e53ed3155bd3d8deb398f3f (4)') 22 | 23 | (size, sha256) = await srcaxon.put(b'vertex') 24 | 25 | outp = self.getTestOutp() 26 | await s_axon2axon.main([srcurl, dsturl, '--offset', '1'], outp=outp) 27 | self.true(await dstaxon.has(sha256)) 28 | outp.expect('Starting transfer at offset: 1') 29 | outp.expect('[ 1] - e1b683e26a3aad218df6aa63afe9cf57fdb5dfaf5eb20cddac14305d67f48a02 (6)') 30 | 31 | outp = self.getTestOutp() 32 | self.eq(1, await s_axon2axon.main([], outp=outp)) 33 | outp.expect('arguments are required:') 34 | -------------------------------------------------------------------------------- /synapse/tests/test_tools_cryo_list.py: -------------------------------------------------------------------------------- 1 | import synapse.tests.utils as s_t_utils 2 | import synapse.tools.cryo.list as s_cryolist 3 | 4 | class CryoListTest(s_t_utils.SynTest): 5 | 6 | async def test_cryolist(self): 7 | 8 | async with self.getTestCryo() as cryo: 9 | 10 | items = [(None, {'key': i}) for i in range(20)] 11 | 12 | tank = await cryo.init('hehe') 13 | await tank.puts(items) 14 | 15 | cryourl = cryo.getLocalUrl() 16 | 17 | argv = [cryourl] 18 | retn, outp = await self.execToolMain(s_cryolist.main, argv) 19 | 20 | self.eq(0, retn) 21 | outp.expect(cryourl) 22 | outp.expect('hehe: ') 23 | outp.expect("'indx': 20,") 24 | outp.expect("'entries': 20}") 25 | -------------------------------------------------------------------------------- /synapse/tests/test_tools_guid.py: -------------------------------------------------------------------------------- 1 | import synapse.common as s_common 2 | 3 | import synapse.tests.utils as s_t_utils 4 | import synapse.tools.guid as s_guid 5 | 6 | class TestGuid(s_t_utils.SynTest): 7 | 8 | def test_tools_guid(self): 9 | argv = [] 10 | outp = self.getTestOutp() 11 | s_guid.main(argv, outp=outp) 12 | self.true(s_common.isguid(str(outp))) 13 | -------------------------------------------------------------------------------- /synapse/tests/test_tools_json2mpk.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | import synapse.tools.json2mpk as s_json2mpk 4 | 5 | import synapse.tests.utils as s_t_utils 6 | 7 | class Json2MpkTest(s_t_utils.SynTest): 8 | 9 | def test_tools_json2mpk(self): 10 | 11 | with self.getTestDir() as ndir: 12 | 13 | outp = self.getTestOutp() 14 | 15 | path = os.path.join(ndir, 'woot.json') 16 | newp = os.path.join(ndir, 'woot.mpk') 17 | fake = os.path.join(ndir, 'fake.json') 18 | html = os.path.join(ndir, 'woot.html') 19 | 20 | self.false(os.path.isfile(path)) 21 | self.false(os.path.isfile(newp)) 22 | 23 | with open(path, 'wb') as fd: 24 | fd.write(b'{"foo":10}\n{"bar":20}\n') 25 | 26 | args = ['--rm', path, fake, html] 27 | 28 | s_json2mpk.main(args, outp=outp) 29 | 30 | with open(newp, 'rb') as fd: 31 | self.eq(fd.read(), b'\x81\xa3foo\n\x81\xa3bar\x14') 32 | 33 | self.false(os.path.isfile(path)) 34 | -------------------------------------------------------------------------------- /synapse/tests/test_tools_livebackup.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | import synapse.common as s_common 4 | 5 | import synapse.lib.output as s_output 6 | import synapse.tests.utils as s_test 7 | import synapse.tools.livebackup as s_t_livebackup 8 | 9 | class LivebackupTest(s_test.SynTest): 10 | 11 | async def test_tools_livebackup(self): 12 | async with self.getTestCore() as core: 13 | 14 | svcurl = core.getLocalUrl() 15 | argv = ( 16 | '--url', svcurl, 17 | '--name', 'visi123', 18 | ) 19 | outp = s_output.OutPutStr() 20 | self.eq(0, await s_t_livebackup.main(argv, outp=outp)) 21 | self.isin(f'Running backup of: {svcurl}', str(outp)) 22 | self.isin(f'...backup created: visi123', str(outp)) 23 | self.true(os.path.isfile(s_common.genpath(core.dirn, 'backups', 'visi123', 'cell.guid'))) 24 | -------------------------------------------------------------------------------- /synapse/tests/test_tools_shutdown.py: -------------------------------------------------------------------------------- 1 | import synapse.common as s_common 2 | 3 | import synapse.lib.output as s_output 4 | 5 | import synapse.tests.utils as s_test 6 | import synapse.tools.shutdown as s_shutdown 7 | 8 | class ShutdownToolTest(s_test.SynTest): 9 | 10 | async def test_tool_shutdown(self): 11 | 12 | async with self.getTestCore() as core: 13 | 14 | msgs = await core.stormlist('background { $lib.time.sleep(10) }') 15 | self.stormHasNoWarnErr(msgs) 16 | 17 | # add a dmon to ensure task.background=True works correctly 18 | await core.addStormDmon({ 19 | 'iden': s_common.guid(), 20 | 'storm': 'while (true) { $lib.time.sleep(1) }', 21 | }) 22 | 23 | argv = ['--url', core.getLocalUrl(), '--timeout', '0'] 24 | 25 | self.eq(1, await s_shutdown.main(argv)) 26 | 27 | for task in core.boss.ps(): 28 | if task.name == 'storm': 29 | await task.kill() 30 | 31 | self.eq(0, await s_shutdown.main(['--url', core.getLocalUrl()])) 32 | 33 | self.true(await core.waitfini(timeout=1)) 34 | 35 | outp = s_output.OutPutStr() 36 | self.eq(1, await s_shutdown.main(['--url', 'newp://hehe'], outp=outp)) 37 | 38 | self.isin('Error while attempting graceful shutdown', str(outp)) 39 | -------------------------------------------------------------------------------- /synapse/tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/synapse/tools/__init__.py -------------------------------------------------------------------------------- /synapse/tools/aha/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/synapse/tools/aha/__init__.py -------------------------------------------------------------------------------- /synapse/tools/aha/provision/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/synapse/tools/aha/provision/__init__.py -------------------------------------------------------------------------------- /synapse/tools/cryo/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/synapse/tools/cryo/__init__.py -------------------------------------------------------------------------------- /synapse/tools/cryo/list.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import logging 3 | import asyncio 4 | import argparse 5 | 6 | import synapse.telepath as s_telepath 7 | 8 | import synapse.lib.output as s_output 9 | 10 | logger = logging.getLogger(__name__) 11 | 12 | async def main(argv, outp=s_output.stdout): 13 | 14 | pars = argparse.ArgumentParser(prog='cryo.list', description='List tanks within a cryo cell.') 15 | pars.add_argument('cryocell', nargs='+', help='Telepath URLs to cryo cells.') 16 | 17 | opts = pars.parse_args(argv) 18 | 19 | for url in opts.cryocell: 20 | 21 | outp.printf(url) 22 | 23 | async with s_telepath.withTeleEnv(): 24 | 25 | async with await s_telepath.openurl(url) as cryo: 26 | 27 | for name, info in await cryo.list(): 28 | outp.printf(f' {name}: {info}') 29 | 30 | return 0 31 | 32 | if __name__ == '__main__': # pragma: no cover 33 | logging.basicConfig() 34 | sys.exit(asyncio.run(main(sys.argv[1:]))) 35 | -------------------------------------------------------------------------------- /synapse/tools/docker/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/synapse/tools/docker/__init__.py -------------------------------------------------------------------------------- /synapse/tools/guid.py: -------------------------------------------------------------------------------- 1 | import synapse.common as s_common 2 | import synapse.lib.output as s_output 3 | 4 | def main(argv, outp=None): 5 | if outp is None: # pragma: no cover 6 | outp = s_output.OutPut() 7 | 8 | outp.printf(s_common.guid()) 9 | 10 | if __name__ == '__main__': # pragma: no cover 11 | import sys 12 | sys.exit(main(sys.argv)) 13 | -------------------------------------------------------------------------------- /synapse/tools/hive/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/synapse/tools/hive/__init__.py -------------------------------------------------------------------------------- /synapse/tools/rstorm.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import asyncio 3 | import logging 4 | import argparse 5 | 6 | import synapse.common as s_common 7 | 8 | import synapse.lib.coro as s_coro 9 | import synapse.lib.output as s_output 10 | import synapse.lib.rstorm as s_rstorm 11 | 12 | logger = logging.getLogger(__name__) 13 | 14 | prog = 'synapse.tools.rstorm' 15 | descr = 'An RST pre-processor that allows you to embed storm directives.' 16 | 17 | async def main(argv, outp=s_output.stdout): 18 | 19 | pars = argparse.ArgumentParser(prog=prog, description=descr) 20 | pars.add_argument('rstfile', help='Input RST file with storm directives.') 21 | pars.add_argument('--save', help='Output file to save (default: stdout)') 22 | 23 | opts = pars.parse_args(argv) 24 | 25 | async with await s_rstorm.StormRst.anit(opts.rstfile) as rstorm: 26 | lines = await rstorm.run() 27 | 28 | if opts.save: 29 | with open(s_common.genpath(opts.save), 'w') as fd: 30 | fd.truncate(0) 31 | [fd.write(line) for line in lines] 32 | else: 33 | for line in lines: 34 | outp.printf(line, addnl=False) 35 | 36 | async def _main(argv, outp=s_output.stdout): # pragma: no cover 37 | s_common.setlogging(logger) 38 | ret = await main(argv, outp=outp) 39 | await asyncio.wait_for(s_coro.await_bg_tasks(), timeout=60) 40 | return ret 41 | 42 | if __name__ == '__main__': 43 | sys.exit(asyncio.run(_main(sys.argv[1:]))) 44 | -------------------------------------------------------------------------------- /synapse/utils/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/synapse/utils/__init__.py -------------------------------------------------------------------------------- /synapse/utils/stormcov/__init__.py: -------------------------------------------------------------------------------- 1 | from .plugin import StormPlugin 2 | 3 | def coverage_init(reg, options): 4 | plugin = StormPlugin(options) 5 | reg.add_configurer(plugin) 6 | reg.add_file_tracer(plugin) 7 | -------------------------------------------------------------------------------- /synapse/vendor/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/synapse/vendor/__init__.py -------------------------------------------------------------------------------- /synapse/vendor/cashaddress/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Shammah Chancellor 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | --------- 24 | 25 | The vendored library is the cashaddress v1.0.6 library for the purposes of Cryptocurrency address validation. 26 | -------------------------------------------------------------------------------- /synapse/vendor/cashaddress/__init__.py: -------------------------------------------------------------------------------- 1 | # It has been modified for vendored imports. 2 | import synapse.vendor.cashaddress.convert 3 | import synapse.vendor.cashaddress.crypto 4 | 5 | __all__ = ['convert', 'convert'] 6 | -------------------------------------------------------------------------------- /synapse/vendor/cashaddress/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/synapse/vendor/cashaddress/tests/__init__.py -------------------------------------------------------------------------------- /synapse/vendor/cpython/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/synapse/vendor/cpython/__init__.py -------------------------------------------------------------------------------- /synapse/vendor/cpython/lib/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/synapse/vendor/cpython/lib/__init__.py -------------------------------------------------------------------------------- /synapse/vendor/cpython/lib/email/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/synapse/vendor/cpython/lib/email/__init__.py -------------------------------------------------------------------------------- /synapse/vendor/cpython/lib/http/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/synapse/vendor/cpython/lib/http/__init__.py -------------------------------------------------------------------------------- /synapse/vendor/cpython/lib/json.py: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | # Taken from the cpython 3.11 source branch after the 3.11.10 release. 3 | ############################################################################## 4 | import codecs 5 | 6 | # vendored from: 7 | # https://github.com/python/cpython/blob/v3.11.10/Lib/json/__init__.py#L244-L271 8 | def detect_encoding(b): 9 | bstartswith = b.startswith 10 | if bstartswith((codecs.BOM_UTF32_BE, codecs.BOM_UTF32_LE)): 11 | return 'utf-32' 12 | if bstartswith((codecs.BOM_UTF16_BE, codecs.BOM_UTF16_LE)): 13 | return 'utf-16' 14 | if bstartswith(codecs.BOM_UTF8): 15 | return 'utf-8-sig' 16 | 17 | if len(b) >= 4: 18 | if not b[0]: 19 | # 00 00 -- -- - utf-32-be 20 | # 00 XX -- -- - utf-16-be 21 | return 'utf-16-be' if b[1] else 'utf-32-be' 22 | if not b[1]: 23 | # XX 00 00 00 - utf-32-le 24 | # XX 00 00 XX - utf-16-le 25 | # XX 00 XX -- - utf-16-le 26 | return 'utf-16-le' if b[2] or b[3] else 'utf-32-le' 27 | elif len(b) == 2: 28 | if not b[0]: 29 | # 00 XX - utf-16-be 30 | return 'utf-16-be' 31 | if not b[1]: 32 | # XX 00 - utf-16-le 33 | return 'utf-16-le' 34 | # default 35 | return 'utf-8' 36 | -------------------------------------------------------------------------------- /synapse/vendor/cpython/lib/test/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/synapse/vendor/cpython/lib/test/__init__.py -------------------------------------------------------------------------------- /synapse/vendor/cpython/lib/test/test_email/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/synapse/vendor/cpython/lib/test/test_email/__init__.py -------------------------------------------------------------------------------- /synapse/vendor/cpython/lib/test/test_json.py: -------------------------------------------------------------------------------- 1 | # From the python source, tests/test_json/test_unicode.py does not have a 2 | # direct test for detect_encoding. It instead tests the various encoding 3 | # schemes in test_bytes_decode, which uses the detection in json.loads(). 4 | # Since there is not a standalone test to vendor, we have written a simple 5 | # test on its own. 6 | 7 | import synapse.vendor.cpython.lib.json as v_json 8 | 9 | import synapse.vendor.utils as s_v_utils 10 | 11 | class JsonVendorTest(s_v_utils.VendorTest): 12 | def test_json_detect_encoding(self): 13 | 14 | ENCODINGS = ( 15 | 'utf-8', 'utf-8-sig', 16 | 'utf-16', 'utf-16-le', 'utf-16-be', 17 | 'utf-32', 'utf-32-le', 'utf-32-be', 18 | ) 19 | 20 | for encoding in ENCODINGS: 21 | self.assertEqual(encoding, v_json.detect_encoding('a'.encode(encoding))) 22 | self.assertEqual(encoding, v_json.detect_encoding('ab'.encode(encoding))) 23 | -------------------------------------------------------------------------------- /synapse/vendor/substrateinterface/__init__.py: -------------------------------------------------------------------------------- 1 | # Python Substrate Interface Library 2 | # 3 | # Copyright 2018-2020 Stichting Polkascan (Polkascan Foundation). 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | # The vendored library is a subset of the substrate-interface v1.0.1 library for the purposes of Cryptocurrency address 18 | # validation. 19 | 20 | # Removed __all__ import 21 | -------------------------------------------------------------------------------- /synapse/vendor/substrateinterface/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/synapse/vendor/substrateinterface/tests/__init__.py -------------------------------------------------------------------------------- /synapse/vendor/substrateinterface/utils/__init__.py: -------------------------------------------------------------------------------- 1 | # Python Substrate Interface Library 2 | # 3 | # Copyright 2018-2020 Stichting Polkascan (Polkascan Foundation). 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | import re 17 | 18 | 19 | def version_tuple(version_string: str) -> tuple: 20 | """ 21 | Converts a basic version string to a tuple that can be compared 22 | 23 | Parameters 24 | ---------- 25 | version_string 26 | 27 | Returns 28 | ------- 29 | tuple 30 | """ 31 | if re.search(r'[^\.0-9]', version_string): 32 | raise ValueError('version_string can only contain numeric characters') 33 | 34 | return tuple(int(v) for v in version_string.split('.')) 35 | -------------------------------------------------------------------------------- /synapse/vendor/utils.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | import synapse.common as s_common 4 | 5 | class VendorTest(unittest.TestCase): 6 | 7 | def setUp(self) -> None: 8 | if not s_common.envbool('SYN_VENDOR_TEST'): # pragma: no cover 9 | raise unittest.SkipTest('Skipping vendored test.') 10 | -------------------------------------------------------------------------------- /synapse/vendor/xrpl/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2021, XRP Ledger Foundation 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. 4 | 5 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 6 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 7 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 8 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 9 | OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 10 | 11 | -----------------------------------------------------------------------------------------------------------------------0 12 | 13 | The vendored library is a subset of the xrpl-py v1.1.1 library for the purposes of Cryptocurrency address validation. 14 | -------------------------------------------------------------------------------- /synapse/vendor/xrpl/__init__.py: -------------------------------------------------------------------------------- 1 | """High-level XRPL exports.""" 2 | # 3 | # Copyright (c) 2021, XRP Ledger Foundation 4 | # 5 | # Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. 6 | # 7 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 8 | # INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 9 | # FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 10 | # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 11 | # OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 12 | # 13 | # -----------------------------------------------------------------------------------------------------------------------0 14 | # 15 | # The vendored library is a subset of the xrpl-py v1.1.1 library for the purposes of Cryptocurrency address validation. 16 | # It has been modified for vendored imports. 17 | # ''' 18 | 19 | from synapse.vendor.xrpl import core 20 | from synapse.vendor.xrpl.constants import CryptoAlgorithm, XRPLException 21 | 22 | __all__ = [ 23 | "CryptoAlgorithm", 24 | "XRPLException", 25 | "core", 26 | ] 27 | -------------------------------------------------------------------------------- /synapse/vendor/xrpl/constants.py: -------------------------------------------------------------------------------- 1 | """Collection of public constants for XRPL.""" 2 | from enum import Enum 3 | from re import compile 4 | from typing import Pattern 5 | 6 | from typing_extensions import Final 7 | 8 | 9 | class CryptoAlgorithm(str, Enum): 10 | """Represents the supported cryptography algorithms.""" 11 | 12 | ED25519 = "ed25519" 13 | SECP256K1 = "secp256k1" 14 | 15 | 16 | class XRPLException(Exception): 17 | """Base Exception for XRPL library.""" 18 | 19 | pass 20 | 21 | 22 | ISO_CURRENCY_REGEX: Final[Pattern[str]] = compile("^[A-Z0-9]{3}$") 23 | """ 24 | :meta private: 25 | """ 26 | 27 | HEX_CURRENCY_REGEX: Final[Pattern[str]] = compile("^[A-F0-9]{40}$") 28 | """ 29 | :meta private: 30 | """ 31 | -------------------------------------------------------------------------------- /synapse/vendor/xrpl/core/__init__.py: -------------------------------------------------------------------------------- 1 | """Core codec functions for interacting with the XRPL.""" 2 | # It has been modified for vendored imports. 3 | from synapse.vendor.xrpl.core import addresscodec 4 | 5 | __all__ = ["addresscodec"] 6 | -------------------------------------------------------------------------------- /synapse/vendor/xrpl/core/addresscodec/__init__.py: -------------------------------------------------------------------------------- 1 | """Functions for encoding and decoding XRP Ledger addresses and seeds.""" 2 | # It has been modified for vendored imports. 3 | from synapse.vendor.xrpl.core.addresscodec.codec import ( 4 | SEED_LENGTH, 5 | decode_account_public_key, 6 | decode_classic_address, 7 | decode_node_public_key, 8 | decode_seed, 9 | encode_account_public_key, 10 | encode_classic_address, 11 | encode_node_public_key, 12 | encode_seed, 13 | is_valid_classic_address, 14 | ) 15 | from synapse.vendor.xrpl.core.addresscodec.exceptions import XRPLAddressCodecException 16 | from synapse.vendor.xrpl.core.addresscodec.main import ( 17 | classic_address_to_xaddress, 18 | is_valid_xaddress, 19 | xaddress_to_classic_address, 20 | ) 21 | from synapse.vendor.xrpl.core.addresscodec.utils import XRPL_ALPHABET 22 | 23 | __all__ = [ 24 | "classic_address_to_xaddress", 25 | "decode_account_public_key", 26 | "decode_classic_address", 27 | "decode_node_public_key", 28 | "decode_seed", 29 | "encode_seed", 30 | "encode_account_public_key", 31 | "encode_classic_address", 32 | "encode_node_public_key", 33 | "is_valid_classic_address", 34 | "is_valid_xaddress", 35 | "SEED_LENGTH", 36 | "xaddress_to_classic_address", 37 | "XRPLAddressCodecException", 38 | "XRPL_ALPHABET", 39 | ] 40 | -------------------------------------------------------------------------------- /synapse/vendor/xrpl/core/addresscodec/exceptions.py: -------------------------------------------------------------------------------- 1 | """General XRPL Address Codec Exceptions.""" 2 | # It has been modified for vendored imports. 3 | from synapse.vendor.xrpl.constants import XRPLException 4 | 5 | 6 | class XRPLAddressCodecException(XRPLException): 7 | """General XRPL Address Codec Exception.""" 8 | 9 | pass 10 | -------------------------------------------------------------------------------- /synapse/vendor/xrpl/core/addresscodec/utils.py: -------------------------------------------------------------------------------- 1 | """This module contains commonly-used constants.""" 2 | from typing_extensions import Final 3 | 4 | # The dictionary used for XRPL base58 encodings 5 | XRPL_ALPHABET: Final[ 6 | bytes 7 | ] = b"rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz" 8 | -------------------------------------------------------------------------------- /synapse/vendor/xrpl/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vertexproject/synapse/d631ab527d49b3c1133420d3afa7dc5e3d5e4c37/synapse/vendor/xrpl/tests/__init__.py --------------------------------------------------------------------------------