ronin 0.3.0 → 1.0.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +4 -0
- data/.rspec +1 -0
- data/.yardopts +5 -0
- data/{History.txt → ChangeLog.md} +15 -15
- data/Gemfile +42 -0
- data/README.md +224 -0
- data/Rakefile +65 -33
- data/bin/ronin +18 -5
- data/bin/ronin-campaigns +25 -0
- data/bin/ronin-console +18 -5
- data/bin/ronin-creds +25 -0
- data/bin/ronin-database +25 -0
- data/bin/ronin-emails +25 -0
- data/bin/ronin-exec +25 -0
- data/bin/ronin-help +18 -5
- data/bin/ronin-hosts +25 -0
- data/bin/ronin-ips +25 -0
- data/bin/ronin-repos +25 -0
- data/bin/ronin-urls +25 -0
- data/gemspec.yml +71 -0
- data/lib/ronin/address.rb +93 -0
- data/lib/ronin/arch.rb +30 -25
- data/lib/ronin/author.rb +12 -42
- data/lib/ronin/bootstrap.rb +26 -0
- data/lib/ronin/cached_file.rb +249 -0
- data/lib/ronin/campaign.rb +130 -0
- data/lib/ronin/class_methods.rb +27 -0
- data/lib/ronin/config.rb +23 -17
- data/lib/ronin/credential.rb +114 -0
- data/lib/ronin/database/database.rb +180 -52
- data/lib/ronin/database/exceptions/invalid_config.rb +2 -2
- data/lib/ronin/{platform/exceptions/extension_not_found.rb → database/exceptions/unknown_repository.rb} +3 -3
- data/lib/ronin/database/exceptions.rb +2 -1
- data/lib/ronin/database/migrations/create_addresses_table.rb +52 -0
- data/lib/ronin/database/migrations/create_arches_table.rb +44 -0
- data/lib/ronin/database/migrations/create_authors_table.rb +47 -0
- data/lib/ronin/database/migrations/create_cached_files_table.rb +47 -0
- data/lib/ronin/database/migrations/create_campaigns_table.rb +42 -0
- data/lib/ronin/database/migrations/create_countries_table.rb +44 -0
- data/lib/ronin/database/migrations/create_credentials_table.rb +59 -0
- data/lib/ronin/database/migrations/create_email_addresses_table.rb +51 -0
- data/lib/ronin/database/migrations/create_host_name_ip_addresses_table.rb +45 -0
- data/lib/ronin/database/migrations/create_ip_address_mac_addresses_table.rb +45 -0
- data/lib/ronin/database/migrations/create_licenses_table.rb +44 -0
- data/lib/ronin/database/migrations/create_open_ports_table.rb +55 -0
- data/lib/ronin/database/migrations/create_organizations_table.rb +47 -0
- data/lib/ronin/database/migrations/create_os_guesses_table.rb +45 -0
- data/lib/ronin/database/migrations/create_os_table.rb +43 -0
- data/lib/ronin/{extensions/array.rb → database/migrations/create_passwords_table.rb} +17 -23
- data/lib/ronin/{ui/command_line/commands/uninstall.rb → database/migrations/create_ports_table.rb} +20 -24
- data/lib/ronin/database/migrations/create_proxies_table.rb +55 -0
- data/lib/ronin/database/migrations/create_remote_files_table.rb +53 -0
- data/lib/ronin/database/migrations/create_repositories_table.rb +61 -0
- data/lib/ronin/{ui/command_line/commands/remove.rb → database/migrations/create_services_table.rb} +20 -24
- data/lib/ronin/database/migrations/create_softwares_table.rb +46 -0
- data/lib/ronin/database/migrations/create_taggings_table.rb +46 -0
- data/lib/ronin/database/migrations/create_tags_table.rb +42 -0
- data/lib/ronin/database/migrations/create_targets_table.rb +50 -0
- data/lib/ronin/{network/imap.rb → database/migrations/create_url_query_params_table.rb} +16 -22
- data/lib/ronin/database/migrations/create_url_schemes_table.rb +40 -0
- data/lib/ronin/database/migrations/create_urls_table.rb +61 -0
- data/lib/ronin/{network/pop3.rb → database/migrations/create_user_names_table.rb} +16 -21
- data/lib/ronin/database/migrations/create_vendors_table.rb +42 -0
- data/lib/ronin/database/migrations/exceptions/duplicate_migration.rb +30 -0
- data/lib/ronin/{network/http/exceptions/unknown_request.rb → database/migrations/exceptions/unknown_migration.rb} +4 -4
- data/lib/ronin/{platform → database/migrations}/exceptions.rb +3 -3
- data/lib/ronin/database/migrations/graph.rb +278 -0
- data/lib/ronin/database/migrations/migration.rb +67 -0
- data/lib/ronin/database/migrations/migrations.rb +186 -0
- data/lib/ronin/database/migrations.rb +55 -0
- data/lib/ronin/database.rb +2 -1
- data/lib/ronin/email_address.rb +133 -0
- data/lib/ronin/engine/buildable.rb +125 -0
- data/lib/ronin/engine/class_methods.rb +133 -0
- data/lib/ronin/engine/deployable.rb +180 -0
- data/lib/ronin/engine/engine.rb +69 -0
- data/lib/ronin/{rpc/exceptions/response_missing.rb → engine/exceptions/deploy_failed.rb} +3 -3
- data/lib/ronin/{rpc/exceptions/not_implemented.rb → engine/exceptions/not_built.rb} +3 -3
- data/lib/ronin/{platform/exceptions/overlay_cached.rb → engine/exceptions/verification_failed.rb} +3 -3
- data/lib/ronin/{rpc → engine}/exceptions.rb +4 -3
- data/lib/ronin/engine/instance_methods.rb +95 -0
- data/lib/ronin/engine/verifiable.rb +334 -0
- data/lib/ronin/{yard.rb → engine.rb} +2 -2
- data/lib/ronin/environment.rb +5 -14
- data/lib/ronin/{platform/exceptions/overlay_not_found.rb → exceptions/duplicate_repository.rb} +2 -4
- data/lib/ronin/exceptions/repository_not_found.rb +24 -0
- data/lib/ronin/{network/http/exceptions.rb → exceptions.rb} +3 -2
- data/lib/ronin/host_name.rb +181 -0
- data/lib/ronin/host_name_ip_address.rb +42 -0
- data/lib/ronin/installation.rb +169 -0
- data/lib/ronin/ip_address.rb +273 -0
- data/lib/ronin/ip_address_mac_address.rb +42 -0
- data/lib/ronin/license.rb +17 -20
- data/lib/ronin/mac_address.rb +68 -0
- data/lib/ronin/model/cacheable/cacheable.rb +280 -0
- data/lib/ronin/model/cacheable/class_methods.rb +61 -0
- data/lib/ronin/model/cacheable.rb +22 -0
- data/lib/ronin/{rpc/response.rb → model/class_methods.rb} +17 -21
- data/lib/ronin/{code/emittable.rb → model/has_authors/class_methods.rb} +27 -34
- data/lib/ronin/model/has_authors/has_authors.rb +63 -0
- data/lib/ronin/model/has_authors.rb +22 -0
- data/lib/ronin/model/has_description/class_methods.rb +44 -0
- data/lib/ronin/model/has_description/has_description.rb +42 -0
- data/lib/ronin/model/has_description.rb +3 -59
- data/lib/ronin/{network/helpers/helper.rb → model/has_license/class_methods.rb} +16 -22
- data/lib/ronin/model/has_license/has_license.rb +64 -0
- data/lib/ronin/model/has_license.rb +3 -38
- data/lib/ronin/model/has_name/class_methods.rb +47 -0
- data/lib/ronin/model/has_name/has_name.rb +53 -0
- data/lib/ronin/model/has_name.rb +3 -33
- data/lib/ronin/model/has_title/class_methods.rb +43 -0
- data/lib/ronin/model/has_title/has_title.rb +41 -0
- data/lib/ronin/model/has_title.rb +22 -0
- data/lib/ronin/model/has_unique_name.rb +52 -0
- data/lib/ronin/model/has_version/class_methods.rb +47 -0
- data/lib/ronin/model/has_version/has_version.rb +41 -0
- data/lib/ronin/model/has_version.rb +3 -37
- data/lib/ronin/model/model.rb +27 -32
- data/lib/ronin/model/types/description.rb +60 -0
- data/lib/ronin/{extensions/meta.rb → model/types.rb} +2 -2
- data/lib/ronin/model.rb +1 -1
- data/lib/ronin/network/mixins/esmtp.rb +152 -0
- data/lib/ronin/network/{helpers → mixins}/http.rb +79 -61
- data/lib/ronin/network/mixins/imap.rb +140 -0
- data/lib/ronin/network/mixins/pop3.rb +130 -0
- data/lib/ronin/network/mixins/smtp.rb +146 -0
- data/lib/ronin/network/{helpers → mixins}/tcp.rb +97 -98
- data/lib/ronin/network/{helpers → mixins}/telnet.rb +71 -41
- data/lib/ronin/network/mixins/udp.rb +210 -0
- data/lib/ronin/network/mixins.rb +29 -0
- data/lib/ronin/open_port.rb +112 -0
- data/lib/ronin/organization.rb +49 -0
- data/lib/ronin/os.rb +61 -11
- data/lib/ronin/os_guess.rb +42 -0
- data/lib/ronin/password.rb +126 -0
- data/lib/ronin/port.rb +71 -0
- data/lib/ronin/proxy.rb +179 -0
- data/lib/ronin/proxy_credential.rb +30 -0
- data/lib/ronin/remote_file.rb +150 -0
- data/lib/ronin/repository.rb +681 -0
- data/lib/ronin/ronin.rb +31 -0
- data/lib/ronin/service.rb +52 -0
- data/lib/ronin/service_credential.rb +30 -0
- data/lib/ronin/{product.rb → software.rb} +12 -34
- data/lib/ronin/spec/database.rb +42 -0
- data/lib/ronin/{extensions/uri/http.rb → spec/ui/output.rb} +6 -8
- data/lib/ronin/target.rb +78 -0
- data/lib/ronin/tcp_port.rb +41 -0
- data/lib/ronin/udp_port.rb +37 -0
- data/lib/ronin/ui/async_console.rb +130 -0
- data/lib/ronin/ui/cli/cli.rb +147 -0
- data/lib/ronin/ui/cli/command.rb +316 -0
- data/lib/ronin/ui/cli/commands/campaigns.rb +130 -0
- data/lib/ronin/ui/{command_line → cli}/commands/console.rb +27 -22
- data/lib/ronin/ui/cli/commands/creds.rb +87 -0
- data/lib/ronin/ui/cli/commands/database.rb +179 -0
- data/lib/ronin/ui/cli/commands/emails.rb +108 -0
- data/lib/ronin/ui/cli/commands/exec.rb +124 -0
- data/lib/ronin/ui/{command_line → cli}/commands/help.rb +17 -14
- data/lib/ronin/ui/cli/commands/hosts.rb +177 -0
- data/lib/ronin/ui/cli/commands/ips.rb +172 -0
- data/lib/ronin/ui/cli/commands/repos.rb +236 -0
- data/lib/ronin/ui/cli/commands/urls.rb +144 -0
- data/lib/ronin/ui/cli/commands.rb +37 -0
- data/lib/ronin/ui/cli/engine_command.rb +104 -0
- data/lib/ronin/ui/{command_line → cli}/exceptions/unknown_command.rb +2 -2
- data/lib/ronin/{formatting/digest.rb → ui/cli/exceptions.rb} +2 -2
- data/lib/ronin/ui/cli/model_command.rb +247 -0
- data/lib/ronin/{formatting/binary.rb → ui/cli.rb} +3 -2
- data/lib/ronin/ui/console.rb +104 -109
- data/lib/ronin/ui/hexdump/extensions/file.rb +1 -1
- data/lib/ronin/ui/hexdump/extensions/kernel.rb +1 -1
- data/lib/ronin/ui/hexdump/extensions.rb +1 -1
- data/lib/ronin/ui/hexdump/hexdump.rb +5 -3
- data/lib/ronin/ui/hexdump.rb +1 -1
- data/lib/ronin/ui/output/helpers.rb +97 -9
- data/lib/ronin/ui/output/output.rb +30 -54
- data/lib/ronin/ui/output/terminal/color.rb +97 -0
- data/lib/ronin/ui/output/terminal/raw.rb +91 -0
- data/lib/ronin/{extensions/uri.rb → ui/output/terminal.rb} +3 -2
- data/lib/ronin/ui/output.rb +1 -1
- data/lib/ronin/ui/shell.rb +55 -90
- data/lib/ronin/ui.rb +1 -1
- data/lib/ronin/url.rb +343 -0
- data/lib/ronin/url_query_param.rb +40 -0
- data/lib/ronin/url_scheme.rb +37 -0
- data/lib/ronin/user_name.rb +45 -0
- data/lib/ronin/vendor.rb +40 -0
- data/lib/ronin/version.rb +2 -2
- data/lib/ronin/web_credential.rb +32 -0
- data/lib/ronin.rb +2 -2
- data/ronin.gemspec +10 -0
- data/spec/arch_spec.rb +1 -2
- data/spec/author_spec.rb +18 -2
- data/spec/cached_file_spec.rb +211 -0
- data/spec/campaign_spec.rb +30 -0
- data/spec/database_spec.rb +5 -0
- data/spec/email_address_spec.rb +35 -0
- data/spec/engine/buildable_spec.rb +51 -0
- data/spec/engine/classes/buildable_class.rb +15 -0
- data/spec/engine/classes/deployable_class.rb +13 -0
- data/spec/engine/classes/engine_class.rb +19 -0
- data/spec/engine/classes/verifiable_class.rb +19 -0
- data/spec/engine/deployable_spec.rb +55 -0
- data/spec/engine/engine_spec.rb +55 -0
- data/spec/engine/verifiable_spec.rb +117 -0
- data/spec/{static/helpers/static1/dir/two.txt → helpers/repos/hello/cache/.keep} +0 -0
- data/spec/helpers/repos/hello/lib/init.rb +1 -0
- data/spec/{platform/helpers/overlays → helpers/repos}/hello/lib/stuff/another_test.rb +0 -0
- data/spec/{platform/helpers/overlays → helpers/repos}/hello/lib/stuff/test.rb +0 -0
- data/spec/helpers/repos/hello/ronin.yml +7 -0
- data/spec/{static/helpers/static1/one.txt → helpers/repos/random/cache/.keep} +0 -0
- data/spec/helpers/repos/random/ronin.yml +7 -0
- data/spec/helpers/repos/test1/cache/cacheable_model/one.rb +15 -0
- data/spec/helpers/repos/test1/ronin.yml +7 -0
- data/spec/helpers/repos/test2/cache/cacheable_model/exceptions.rb +7 -0
- data/spec/helpers/repos/test2/cache/cacheable_model/load_errors.rb +9 -0
- data/spec/helpers/repos/test2/cache/cacheable_model/no_method_errors.rb +9 -0
- data/spec/helpers/repos/test2/cache/cacheable_model/syntax_errors.rb +7 -0
- data/spec/helpers/repos/test2/cache/cacheable_model/two.rb +15 -0
- data/spec/helpers/repos/test2/cache/cacheable_model/validation_errors.rb +9 -0
- data/spec/helpers/repos/test2/ronin.yml +7 -0
- data/spec/helpers/repositories.rb +11 -0
- data/spec/host_name_spec.rb +51 -0
- data/spec/installation_spec.rb +45 -0
- data/spec/ip_address.rb +67 -0
- data/spec/license_spec.rb +1 -2
- data/spec/mac_address_spec.rb +18 -0
- data/spec/model/cacheable_spec.rb +93 -0
- data/spec/model/has_description_spec.rb +45 -26
- data/spec/model/has_license_spec.rb +18 -17
- data/spec/model/has_name_spec.rb +35 -0
- data/spec/model/has_title_spec.rb +27 -0
- data/spec/model/model_spec.rb +27 -19
- data/spec/model/{classes → models}/basic_model.rb +0 -0
- data/spec/model/models/cacheable_model.rb +15 -0
- data/spec/model/{classes → models}/custom_model.rb +1 -1
- data/spec/model/{classes → models}/described_model.rb +0 -0
- data/spec/model/models/lazy_model.rb +9 -0
- data/spec/model/{classes → models}/licensed_model.rb +0 -0
- data/spec/model/models/named_model.rb +10 -0
- data/spec/model/models/titled_model.rb +10 -0
- data/spec/model/spec_helper.rb +22 -0
- data/spec/os_spec.rb +1 -2
- data/spec/password_spec.rb +35 -0
- data/spec/repository_spec.rb +291 -0
- data/spec/ronin_spec.rb +19 -5
- data/spec/software_spec.rb +23 -0
- data/spec/spec_helper.rb +35 -4
- data/spec/support/inflector_spec.rb +20 -0
- data/spec/ui/cli/classes/test_command.rb +11 -0
- data/spec/ui/cli/command_spec.rb +21 -0
- data/spec/ui/output_spec.rb +20 -17
- data/spec/url_spec.rb +111 -0
- data/spec/vendor_spec.rb +18 -0
- metadata +761 -421
- data/Manifest.txt +0 -290
- data/README.txt +0 -206
- data/bin/ronin-add +0 -12
- data/bin/ronin-install +0 -12
- data/bin/ronin-list +0 -12
- data/bin/ronin-remove +0 -12
- data/bin/ronin-uninstall +0 -12
- data/bin/ronin-update +0 -12
- data/lib/ronin/cacheable.rb +0 -307
- data/lib/ronin/code/reference.rb +0 -130
- data/lib/ronin/code/symbol_table.rb +0 -100
- data/lib/ronin/code/token.rb +0 -69
- data/lib/ronin/extensions/file.rb +0 -38
- data/lib/ronin/extensions/ip_addr.rb +0 -147
- data/lib/ronin/extensions/kernel.rb +0 -97
- data/lib/ronin/extensions/meta/object.rb +0 -24
- data/lib/ronin/extensions/string.rb +0 -119
- data/lib/ronin/extensions/uri/query_params.rb +0 -126
- data/lib/ronin/extensions.rb +0 -26
- data/lib/ronin/formatting/extensions/binary/file.rb +0 -35
- data/lib/ronin/formatting/extensions/binary/integer.rb +0 -106
- data/lib/ronin/formatting/extensions/binary/string.rb +0 -285
- data/lib/ronin/formatting/extensions/binary.rb +0 -22
- data/lib/ronin/formatting/extensions/digest/string.rb +0 -87
- data/lib/ronin/formatting/extensions/digest.rb +0 -21
- data/lib/ronin/formatting/extensions/http/string.rb +0 -88
- data/lib/ronin/formatting/extensions/http.rb +0 -21
- data/lib/ronin/formatting/extensions/text/array.rb +0 -77
- data/lib/ronin/formatting/extensions/text/string.rb +0 -162
- data/lib/ronin/formatting/extensions/text.rb +0 -22
- data/lib/ronin/formatting/extensions.rb +0 -22
- data/lib/ronin/formatting/http.rb +0 -21
- data/lib/ronin/formatting/text.rb +0 -21
- data/lib/ronin/formatting.rb +0 -25
- data/lib/ronin/network/esmtp.rb +0 -21
- data/lib/ronin/network/extensions/esmtp/net.rb +0 -96
- data/lib/ronin/network/extensions/esmtp.rb +0 -21
- data/lib/ronin/network/extensions/http/net.rb +0 -607
- data/lib/ronin/network/extensions/http.rb +0 -21
- data/lib/ronin/network/extensions/imap/net.rb +0 -119
- data/lib/ronin/network/extensions/imap.rb +0 -21
- data/lib/ronin/network/extensions/pop3/net.rb +0 -88
- data/lib/ronin/network/extensions/pop3.rb +0 -21
- data/lib/ronin/network/extensions/smtp/net.rb +0 -108
- data/lib/ronin/network/extensions/smtp.rb +0 -21
- data/lib/ronin/network/extensions/tcp/net.rb +0 -313
- data/lib/ronin/network/extensions/tcp.rb +0 -21
- data/lib/ronin/network/extensions/telnet/net.rb +0 -151
- data/lib/ronin/network/extensions/telnet.rb +0 -21
- data/lib/ronin/network/extensions/udp/net.rb +0 -224
- data/lib/ronin/network/extensions/udp.rb +0 -21
- data/lib/ronin/network/extensions.rb +0 -28
- data/lib/ronin/network/helpers/esmtp.rb +0 -129
- data/lib/ronin/network/helpers/imap.rb +0 -115
- data/lib/ronin/network/helpers/pop3.rb +0 -110
- data/lib/ronin/network/helpers/smtp.rb +0 -123
- data/lib/ronin/network/helpers/udp.rb +0 -197
- data/lib/ronin/network/helpers.rb +0 -29
- data/lib/ronin/network/http/http.rb +0 -214
- data/lib/ronin/network/http/proxy.rb +0 -308
- data/lib/ronin/network/http.rb +0 -23
- data/lib/ronin/network/smtp/email.rb +0 -142
- data/lib/ronin/network/smtp/smtp.rb +0 -67
- data/lib/ronin/network/smtp.rb +0 -23
- data/lib/ronin/network/tcp.rb +0 -21
- data/lib/ronin/network/telnet.rb +0 -108
- data/lib/ronin/network/udp.rb +0 -21
- data/lib/ronin/network.rb +0 -28
- data/lib/ronin/path.rb +0 -90
- data/lib/ronin/platform/extension.rb +0 -446
- data/lib/ronin/platform/extension_cache.rb +0 -143
- data/lib/ronin/platform/maintainer.rb +0 -69
- data/lib/ronin/platform/object_cache.rb +0 -124
- data/lib/ronin/platform/overlay.rb +0 -353
- data/lib/ronin/platform/overlay_cache.rb +0 -447
- data/lib/ronin/platform/platform.rb +0 -304
- data/lib/ronin/platform/ronin.rb +0 -97
- data/lib/ronin/platform/tasks/spec.rb +0 -9
- data/lib/ronin/platform.rb +0 -24
- data/lib/ronin/rpc/call.rb +0 -72
- data/lib/ronin/rpc/client.rb +0 -88
- data/lib/ronin/rpc/console.rb +0 -78
- data/lib/ronin/rpc/service.rb +0 -66
- data/lib/ronin/rpc/shell.rb +0 -63
- data/lib/ronin/rpc.rb +0 -24
- data/lib/ronin/scanners/exceptions/unknown_category.rb +0 -26
- data/lib/ronin/scanners/exceptions.rb +0 -21
- data/lib/ronin/scanners/scanner.rb +0 -295
- data/lib/ronin/scanners.rb +0 -22
- data/lib/ronin/static/finders.rb +0 -165
- data/lib/ronin/static/static.rb +0 -62
- data/lib/ronin/static.rb +0 -22
- data/lib/ronin/templates/erb.rb +0 -70
- data/lib/ronin/templates/template.rb +0 -130
- data/lib/ronin/templates.rb +0 -22
- data/lib/ronin/ui/command_line/command.rb +0 -216
- data/lib/ronin/ui/command_line/command_line.rb +0 -151
- data/lib/ronin/ui/command_line/commands/add.rb +0 -79
- data/lib/ronin/ui/command_line/commands/install.rb +0 -69
- data/lib/ronin/ui/command_line/commands/list.rb +0 -105
- data/lib/ronin/ui/command_line/commands/update.rb +0 -59
- data/lib/ronin/ui/command_line/exceptions.rb +0 -21
- data/lib/ronin/ui/command_line.rb +0 -22
- data/lib/ronin/ui/output/handler.rb +0 -121
- data/lib/ronin/yard/handlers/ruby/base.rb +0 -27
- data/lib/ronin/yard/handlers/ruby/belongs_to_handler.rb +0 -45
- data/lib/ronin/yard/handlers/ruby/eval_block_handler.rb +0 -18
- data/lib/ronin/yard/handlers/ruby/has_handler.rb +0 -49
- data/lib/ronin/yard/handlers/ruby/legacy/belongs_to_handler.rb +0 -41
- data/lib/ronin/yard/handlers/ruby/legacy/eval_block_handler.rb +0 -19
- data/lib/ronin/yard/handlers/ruby/legacy/has_handler.rb +0 -34
- data/lib/ronin/yard/handlers/ruby/legacy/metaclass_eval_handler.rb +0 -21
- data/lib/ronin/yard/handlers/ruby/legacy/property_handler.rb +0 -41
- data/lib/ronin/yard/handlers/ruby/legacy/scanner_handler.rb +0 -61
- data/lib/ronin/yard/handlers/ruby/legacy.rb +0 -26
- data/lib/ronin/yard/handlers/ruby/metaclass_eval_handler.rb +0 -18
- data/lib/ronin/yard/handlers/ruby/property_handler.rb +0 -45
- data/lib/ronin/yard/handlers/ruby/scanner_handler.rb +0 -66
- data/lib/ronin/yard/handlers/ruby.rb +0 -27
- data/lib/ronin/yard/handlers.rb +0 -24
- data/spec/cacheable_spec.rb +0 -150
- data/spec/classes/cacheable_model.rb +0 -15
- data/spec/code/classes/thing.rb +0 -17
- data/spec/code/reference_spec.rb +0 -63
- data/spec/code/symbol_table_spec.rb +0 -45
- data/spec/extensions/array_spec.rb +0 -34
- data/spec/extensions/classes/some_class.rb +0 -2
- data/spec/extensions/ip_addr_spec.rb +0 -44
- data/spec/extensions/kernel_spec.rb +0 -76
- data/spec/extensions/string_spec.rb +0 -103
- data/spec/extensions/uri/http_spec.rb +0 -9
- data/spec/extensions/uri/query_params_spec.rb +0 -46
- data/spec/formatting/binary/helpers/hexdumps/hexdump_decimal_shorts.txt +0 -17
- data/spec/formatting/binary/helpers/hexdumps/hexdump_hex_bytes.txt +0 -17
- data/spec/formatting/binary/helpers/hexdumps/hexdump_hex_shorts.txt +0 -17
- data/spec/formatting/binary/helpers/hexdumps/hexdump_octal_bytes.txt +0 -17
- data/spec/formatting/binary/helpers/hexdumps/hexdump_octal_shorts.txt +0 -17
- data/spec/formatting/binary/helpers/hexdumps/hexdump_repeated.txt +0 -6
- data/spec/formatting/binary/helpers/hexdumps/od_decimal_bytes.txt +0 -17
- data/spec/formatting/binary/helpers/hexdumps/od_decimal_ints.txt +0 -17
- data/spec/formatting/binary/helpers/hexdumps/od_decimal_quads.txt +0 -17
- data/spec/formatting/binary/helpers/hexdumps/od_decimal_shorts.txt +0 -17
- data/spec/formatting/binary/helpers/hexdumps/od_hex_bytes.txt +0 -17
- data/spec/formatting/binary/helpers/hexdumps/od_hex_ints.txt +0 -17
- data/spec/formatting/binary/helpers/hexdumps/od_hex_quads.txt +0 -17
- data/spec/formatting/binary/helpers/hexdumps/od_hex_shorts.txt +0 -17
- data/spec/formatting/binary/helpers/hexdumps/od_octal_bytes.txt +0 -17
- data/spec/formatting/binary/helpers/hexdumps/od_octal_ints.txt +0 -17
- data/spec/formatting/binary/helpers/hexdumps/od_octal_quads.txt +0 -17
- data/spec/formatting/binary/helpers/hexdumps/od_octal_shorts.txt +0 -17
- data/spec/formatting/binary/helpers/hexdumps/od_repeated.txt +0 -6
- data/spec/formatting/binary/helpers/hexdumps/repeated.bin +0 -1
- data/spec/formatting/binary/helpers/hexdumps.rb +0 -14
- data/spec/formatting/binary/integer_spec.rb +0 -131
- data/spec/formatting/binary/string_spec.rb +0 -251
- data/spec/formatting/digest/string_spec.rb +0 -80
- data/spec/formatting/http/string_spec.rb +0 -80
- data/spec/formatting/text/array_spec.rb +0 -64
- data/spec/formatting/text/string_spec.rb +0 -147
- data/spec/helpers/cacheable.rb +0 -7
- data/spec/helpers/contexts/ronin_cacheable_model.rb +0 -13
- data/spec/helpers/database.rb +0 -5
- data/spec/network/helpers/classes/test_helper.rb +0 -11
- data/spec/network/helpers/classes/uses_test_helper.rb +0 -10
- data/spec/network/helpers/helper_spec.rb +0 -25
- data/spec/network/http/http_spec.rb +0 -197
- data/spec/network/http/proxy_spec.rb +0 -116
- data/spec/path_spec.rb +0 -32
- data/spec/platform/extension_cache_spec.rb +0 -64
- data/spec/platform/extension_spec.rb +0 -73
- data/spec/platform/helpers/overlays/hello/hello/extension.rb +0 -7
- data/spec/platform/helpers/overlays/hello/lib/init.rb +0 -1
- data/spec/platform/helpers/overlays/hello/ronin.xml +0 -26
- data/spec/platform/helpers/overlays/random/random/extension.rb +0 -7
- data/spec/platform/helpers/overlays/random/ronin.xml +0 -26
- data/spec/platform/helpers/overlays/test1/ronin.xml +0 -26
- data/spec/platform/helpers/overlays/test1/test/extension.rb +0 -7
- data/spec/platform/helpers/overlays/test2/ronin.xml +0 -26
- data/spec/platform/helpers/overlays/test2/test/extension.rb +0 -7
- data/spec/platform/helpers/overlays.rb +0 -18
- data/spec/platform/helpers/overlays.yaml.erb +0 -13
- data/spec/platform/maintainer_spec.rb +0 -30
- data/spec/platform/overlay_cache_spec.rb +0 -65
- data/spec/platform/overlay_spec.rb +0 -63
- data/spec/platform/platform_spec.rb +0 -22
- data/spec/platform/ronin_spec.rb +0 -34
- data/spec/product_spec.rb +0 -23
- data/spec/scanners/classes/another_scanner.rb +0 -16
- data/spec/scanners/classes/example_scanner.rb +0 -22
- data/spec/scanners/scanner_spec.rb +0 -148
- data/spec/static/classes/static_class.rb +0 -7
- data/spec/static/finders_spec.rb +0 -55
- data/spec/static/helpers/static.rb +0 -10
- data/spec/static/helpers/static2/dir/two.txt +0 -0
- data/spec/static/static_spec.rb +0 -25
- data/spec/templates/classes/example_erb.rb +0 -11
- data/spec/templates/classes/example_template.rb +0 -21
- data/spec/templates/erb_spec.rb +0 -20
- data/spec/templates/helpers/static/templates/_relative.erb +0 -1
- data/spec/templates/helpers/static/templates/example.erb +0 -1
- data/spec/templates/helpers/static.rb +0 -5
- data/spec/templates/template_spec.rb +0 -41
- data/spec/ui/command_line/classes/test_command.rb +0 -23
- data/spec/ui/command_line/command_spec.rb +0 -31
- data/static/ronin/platform/overlay.xsl +0 -203
- data/tasks/spec.rb +0 -10
- data/tasks/yard.rb +0 -18
- data.tar.gz.sig +0 -0
- metadata.gz.sig +0 -0
@@ -0,0 +1,681 @@
|
|
1
|
+
#
|
2
|
+
# Ronin - A Ruby platform for exploit development and security research.
|
3
|
+
#
|
4
|
+
# Copyright (c) 2006-2010 Hal Brodigan (postmodern.mod3 at gmail.com)
|
5
|
+
#
|
6
|
+
# This program is free software; you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation; either version 2 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with this program; if not, write to the Free Software
|
18
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
19
|
+
#
|
20
|
+
|
21
|
+
require 'ronin/exceptions/duplicate_repository'
|
22
|
+
require 'ronin/exceptions/repository_not_found'
|
23
|
+
require 'ronin/cached_file'
|
24
|
+
require 'ronin/model/has_license'
|
25
|
+
require 'ronin/model/has_authors'
|
26
|
+
require 'ronin/model'
|
27
|
+
require 'ronin/config'
|
28
|
+
|
29
|
+
require 'pullr'
|
30
|
+
require 'data_paths'
|
31
|
+
require 'yaml'
|
32
|
+
|
33
|
+
module Ronin
|
34
|
+
class Repository
|
35
|
+
|
36
|
+
include Model
|
37
|
+
include Model::HasAuthors
|
38
|
+
include Model::HasLicense
|
39
|
+
include DataPaths
|
40
|
+
|
41
|
+
# The default domain that repositories are added from
|
42
|
+
LOCAL_DOMAIN = 'localhost'
|
43
|
+
|
44
|
+
# Repository metadata file name
|
45
|
+
METADATA_FILE = 'ronin.yml'
|
46
|
+
|
47
|
+
# Repository `bin/` directory
|
48
|
+
BIN_DIR = 'bin'
|
49
|
+
|
50
|
+
# Repository `lib/` directory
|
51
|
+
LIB_DIR = 'lib'
|
52
|
+
|
53
|
+
# The `init.rb` file to load from the {LIB_DIR}
|
54
|
+
INIT_FILE = 'init.rb'
|
55
|
+
|
56
|
+
# Repository `data/` directory
|
57
|
+
DATA_DIR = 'data'
|
58
|
+
|
59
|
+
# Repository `cache/` directory
|
60
|
+
CACHE_DIR = 'cache'
|
61
|
+
|
62
|
+
# The primary key of the repository
|
63
|
+
property :id, Serial
|
64
|
+
|
65
|
+
# The SCM used by the repository
|
66
|
+
property :scm, String
|
67
|
+
|
68
|
+
# Local path to the repository
|
69
|
+
property :path, FilePath, :required => true, :unique => true
|
70
|
+
|
71
|
+
# URI that the repository was installed from
|
72
|
+
property :uri, URI
|
73
|
+
|
74
|
+
# Specifies whether the repository was installed remotely
|
75
|
+
# or added using a local directory.
|
76
|
+
property :installed, Boolean, :default => false
|
77
|
+
|
78
|
+
# Name of the repository
|
79
|
+
property :name, String, :default => lambda { |repo,name|
|
80
|
+
repo.path.basename
|
81
|
+
}
|
82
|
+
|
83
|
+
# The domain the repository belongs to
|
84
|
+
property :domain, String, :required => true
|
85
|
+
|
86
|
+
# Title of the repository
|
87
|
+
property :title, Text
|
88
|
+
|
89
|
+
# Source View URI of the repository
|
90
|
+
property :source, URI
|
91
|
+
|
92
|
+
# Website URI for the repository
|
93
|
+
property :website, URI
|
94
|
+
|
95
|
+
# Description of the repository
|
96
|
+
property :description, Text
|
97
|
+
|
98
|
+
# The cached files from the repository
|
99
|
+
has 0..n, :cached_files
|
100
|
+
|
101
|
+
# The `bin/` directory
|
102
|
+
attr_reader :bin_dir
|
103
|
+
|
104
|
+
# The `lib/` directory
|
105
|
+
attr_reader :lib_dir
|
106
|
+
|
107
|
+
# The `data/` directory
|
108
|
+
attr_reader :data_dir
|
109
|
+
|
110
|
+
# The `cache/` directory
|
111
|
+
attr_reader :cache_dir
|
112
|
+
|
113
|
+
#
|
114
|
+
# Creates a new {Repository} object.
|
115
|
+
#
|
116
|
+
# @param [Hash] attributes
|
117
|
+
# The attributes of the repository.
|
118
|
+
#
|
119
|
+
# @param [String] path
|
120
|
+
# The path to the repository.
|
121
|
+
#
|
122
|
+
# @param [Symbol] scm
|
123
|
+
# The SCM used by the repository. Can be either `:git`, `:mercurial`,
|
124
|
+
# `:sub_version` or `:rsync`.
|
125
|
+
#
|
126
|
+
# @param [String, URI::HTTP, URI::HTTPS] uri
|
127
|
+
# The URI the repository resides at.
|
128
|
+
#
|
129
|
+
# @yield [repo]
|
130
|
+
# If a block is given, the repository will be passed to it.
|
131
|
+
#
|
132
|
+
# @yieldparam [Repository] repo
|
133
|
+
# The newly created repository.
|
134
|
+
#
|
135
|
+
def initialize(attributes={})
|
136
|
+
super(attributes)
|
137
|
+
|
138
|
+
@bin_dir = self.path.join(BIN_DIR)
|
139
|
+
@lib_dir = self.path.join(LIB_DIR)
|
140
|
+
@data_dir = self.path.join(DATA_DIR)
|
141
|
+
@cache_dir = self.path.join(CACHE_DIR)
|
142
|
+
|
143
|
+
@activated = false
|
144
|
+
|
145
|
+
initialize_metadata
|
146
|
+
|
147
|
+
yield self if block_given?
|
148
|
+
end
|
149
|
+
|
150
|
+
#
|
151
|
+
# Searches for the Repository with a given name, and potentially
|
152
|
+
# installed from the given domain.
|
153
|
+
#
|
154
|
+
# @param [String] name
|
155
|
+
# The name of the repository.
|
156
|
+
#
|
157
|
+
# @return [Repository]
|
158
|
+
# The matching repository.
|
159
|
+
#
|
160
|
+
# @raise [RepositoryNotFound]
|
161
|
+
# No repository could be found with the given name or domain.
|
162
|
+
#
|
163
|
+
# @example Load the repository with the given name
|
164
|
+
# Repository.find('postmodern-repo')
|
165
|
+
#
|
166
|
+
# @example Load the repository with the given name and domain.
|
167
|
+
# Repository.find('postmodern-repo/github.com')
|
168
|
+
#
|
169
|
+
# @since 1.0.0
|
170
|
+
#
|
171
|
+
def Repository.find(name)
|
172
|
+
name, domain = name.to_s.split('/',2)
|
173
|
+
|
174
|
+
query = {:name => name}
|
175
|
+
query[:domain] = domain if domain
|
176
|
+
|
177
|
+
unless (repo = Repository.first(query))
|
178
|
+
if domain
|
179
|
+
raise(RepositoryNotFound,"Repository #{name.dump} from domain #{domain.dump} cannot be found")
|
180
|
+
else
|
181
|
+
raise(RepositoryNotFound,"Repository #{name.dump} cannot be found")
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
return repo
|
186
|
+
end
|
187
|
+
|
188
|
+
#
|
189
|
+
# Adds an Repository with the given options.
|
190
|
+
#
|
191
|
+
# @return [Repository]
|
192
|
+
# The added repository.
|
193
|
+
#
|
194
|
+
# @raise [ArgumentError]
|
195
|
+
# The `:path` option was not specified.
|
196
|
+
#
|
197
|
+
# @raise [RepositoryNotFound]
|
198
|
+
# The path of the repository did not exist or was not a directory.
|
199
|
+
#
|
200
|
+
# @raise [DuplicateRepository]
|
201
|
+
# The repository was already added or installed.
|
202
|
+
#
|
203
|
+
# @since 1.0.0
|
204
|
+
#
|
205
|
+
def Repository.add!(options={})
|
206
|
+
unless options.has_key?(:path)
|
207
|
+
raise(ArgumentError,"the :path option was not given")
|
208
|
+
end
|
209
|
+
|
210
|
+
path = Pathname.new(options[:path]).expand_path
|
211
|
+
|
212
|
+
unless path.directory?
|
213
|
+
raise(RepositoryNotFound,"Repository #{path} cannot be found")
|
214
|
+
end
|
215
|
+
|
216
|
+
if Repository.count(:path => path) > 0
|
217
|
+
raise(DuplicateRepository,"a Repository at the path #{path} was already added")
|
218
|
+
end
|
219
|
+
|
220
|
+
# create the repository
|
221
|
+
repo = Repository.new(options.merge(
|
222
|
+
:path => path,
|
223
|
+
:installed => false,
|
224
|
+
:domain => LOCAL_DOMAIN
|
225
|
+
))
|
226
|
+
|
227
|
+
name = repo.name
|
228
|
+
domain = repo.domain
|
229
|
+
|
230
|
+
if Repository.count(:name => name, :domain => domain) > 0
|
231
|
+
raise(DuplicateRepository,"the Repository #{repo} already exists in the database")
|
232
|
+
end
|
233
|
+
|
234
|
+
# save the repository
|
235
|
+
if repo.save
|
236
|
+
# cache any files from within the `cache/` directory of the
|
237
|
+
# repository
|
238
|
+
repo.cache_files!
|
239
|
+
end
|
240
|
+
|
241
|
+
return repo
|
242
|
+
end
|
243
|
+
|
244
|
+
#
|
245
|
+
# Installs an repository.
|
246
|
+
#
|
247
|
+
# @param [Hash] options
|
248
|
+
# Additional options.
|
249
|
+
#
|
250
|
+
# @option options [Addressable::URI, String] :uri
|
251
|
+
# The URI to the repository.
|
252
|
+
#
|
253
|
+
# @option options [Symbol] :scm
|
254
|
+
# The SCM used by the repository. May be either `:git`, `:mercurial`,
|
255
|
+
# `:sub_version` or `:rsync`.
|
256
|
+
#
|
257
|
+
# @return [Repository]
|
258
|
+
# The newly installed repository.
|
259
|
+
#
|
260
|
+
# @raise [ArgumentError]
|
261
|
+
# The `:uri` option must be specified.
|
262
|
+
#
|
263
|
+
# @raise [DuplicateRepository]
|
264
|
+
# An repository already exists with the same `name` and `host`
|
265
|
+
# properties.
|
266
|
+
#
|
267
|
+
# @since 1.0.0
|
268
|
+
#
|
269
|
+
def Repository.install!(options={})
|
270
|
+
unless options[:uri]
|
271
|
+
raise(ArgumentError,":uri must be passed to Repository.install")
|
272
|
+
end
|
273
|
+
|
274
|
+
remote_repo = Pullr::RemoteRepository.new(options)
|
275
|
+
name = remote_repo.name
|
276
|
+
domain = if remote_repo.uri.scheme
|
277
|
+
remote_repo.uri.host
|
278
|
+
else
|
279
|
+
# Use a regexp to pull out the host-name, if the URI
|
280
|
+
# lacks a scheme.
|
281
|
+
remote_repo.uri.to_s.match(/\@([^@:\/]+)/)[1]
|
282
|
+
end
|
283
|
+
|
284
|
+
if Repository.count(:name => name, :domain => domain) > 0
|
285
|
+
raise(DuplicateRepository,"a Repository already exists with the name #{name.dump} from domain #{domain.dump}")
|
286
|
+
end
|
287
|
+
|
288
|
+
path = File.join(Config::REPOS_DIR,name,domain)
|
289
|
+
|
290
|
+
# pull down the remote repository
|
291
|
+
local_repo = remote_repo.pull(path)
|
292
|
+
|
293
|
+
# add the new remote repository
|
294
|
+
repo = Repository.new(
|
295
|
+
:path => path,
|
296
|
+
:scm => local_repo.scm,
|
297
|
+
:uri => remote_repo.uri,
|
298
|
+
:installed => true,
|
299
|
+
:name => name,
|
300
|
+
:domain => domain
|
301
|
+
)
|
302
|
+
|
303
|
+
# save the repository
|
304
|
+
if repo.save
|
305
|
+
# cache any files from within the `cache/` directory of the
|
306
|
+
# repository
|
307
|
+
repo.cache_files!
|
308
|
+
end
|
309
|
+
|
310
|
+
return repo
|
311
|
+
end
|
312
|
+
|
313
|
+
#
|
314
|
+
# Updates all repositories.
|
315
|
+
#
|
316
|
+
# @yield [repo]
|
317
|
+
# If a block is given, it will be passed each updated repository.
|
318
|
+
#
|
319
|
+
# @yieldparam [Repository] repo
|
320
|
+
# An updated repository.
|
321
|
+
#
|
322
|
+
# @since 1.0.0
|
323
|
+
#
|
324
|
+
def Repository.update!
|
325
|
+
Repository.each do |repo|
|
326
|
+
# update the repositories contents
|
327
|
+
repo.update!
|
328
|
+
|
329
|
+
yield repo if block_given?
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
333
|
+
#
|
334
|
+
# Uninstalls the repository with the given name or domain.
|
335
|
+
#
|
336
|
+
# @param [String] name
|
337
|
+
# The name of the repository to uninstall.
|
338
|
+
#
|
339
|
+
# @return [nil]
|
340
|
+
#
|
341
|
+
# @example Uninstall the repository with the given name
|
342
|
+
# Repository.uninstall!('postmodern-repo')
|
343
|
+
#
|
344
|
+
# @example Uninstall the repository with the given name and domain.
|
345
|
+
# Repository.uninstall!('postmodern-repo/github.com')
|
346
|
+
#
|
347
|
+
def Repository.uninstall!(name)
|
348
|
+
Repository.find(name).uninstall!
|
349
|
+
end
|
350
|
+
|
351
|
+
#
|
352
|
+
# Activates all installed or added repositories.
|
353
|
+
#
|
354
|
+
# @return [Array<Repository>]
|
355
|
+
# The activated repository.
|
356
|
+
#
|
357
|
+
# @see #activate!
|
358
|
+
#
|
359
|
+
# @since 1.0.0
|
360
|
+
#
|
361
|
+
def Repository.activate!
|
362
|
+
Repository.each { |repo| repo.activate! }
|
363
|
+
end
|
364
|
+
|
365
|
+
#
|
366
|
+
# De-activates all installed or added repositories.
|
367
|
+
#
|
368
|
+
# @return [Array<Repository>]
|
369
|
+
# The de-activated repositories.
|
370
|
+
#
|
371
|
+
# @see #deactivate!
|
372
|
+
#
|
373
|
+
# @since 1.0.0
|
374
|
+
#
|
375
|
+
def Repository.deactivate!
|
376
|
+
Repository.reverse_each { |repo| repo.deactivate! }
|
377
|
+
end
|
378
|
+
|
379
|
+
#
|
380
|
+
# Determines if the repository was added locally.
|
381
|
+
#
|
382
|
+
# @return [Boolean]
|
383
|
+
# Specifies whether the repository was added locally.
|
384
|
+
#
|
385
|
+
# @since 1.0.0
|
386
|
+
#
|
387
|
+
def local?
|
388
|
+
self.domain == LOCAL_DOMAIN
|
389
|
+
end
|
390
|
+
|
391
|
+
#
|
392
|
+
# Determines if the repository was installed remotely.
|
393
|
+
#
|
394
|
+
# @return [Boolean]
|
395
|
+
# Specifies whether the repository was installed from a remote URI.
|
396
|
+
#
|
397
|
+
# @since 1.0.0
|
398
|
+
#
|
399
|
+
def remote?
|
400
|
+
self.domain != LOCAL_DOMAIN
|
401
|
+
end
|
402
|
+
|
403
|
+
#
|
404
|
+
# The executable scripts in the `bin/` directory.
|
405
|
+
#
|
406
|
+
# @return [Array<String>]
|
407
|
+
# The executable script names.
|
408
|
+
#
|
409
|
+
# @since 1.0.0
|
410
|
+
#
|
411
|
+
def executables
|
412
|
+
scripts = []
|
413
|
+
|
414
|
+
if @bin_dir.directory?
|
415
|
+
@bin_dir.entries.each do |path|
|
416
|
+
scripts << path.basename.to_s if path.file?
|
417
|
+
end
|
418
|
+
end
|
419
|
+
|
420
|
+
return scripts
|
421
|
+
end
|
422
|
+
|
423
|
+
#
|
424
|
+
# All paths within the `cache/` directory of the repository.
|
425
|
+
#
|
426
|
+
# @return [Array<Pathname>]
|
427
|
+
# The paths within the `cache/` directory.
|
428
|
+
#
|
429
|
+
# @since 1.0.0
|
430
|
+
#
|
431
|
+
def cache_paths
|
432
|
+
Pathname.glob(@cache_dir.join('**','*.rb'))
|
433
|
+
end
|
434
|
+
|
435
|
+
#
|
436
|
+
# Determines if the repository has been activated.
|
437
|
+
#
|
438
|
+
# @return [Boolean]
|
439
|
+
# Specifies whether the repository has been activated.
|
440
|
+
#
|
441
|
+
def activated?
|
442
|
+
@activated == true
|
443
|
+
end
|
444
|
+
|
445
|
+
#
|
446
|
+
# Activates the repository by adding the {#lib_dir} to the `$LOAD_PATH`
|
447
|
+
# global variable.
|
448
|
+
#
|
449
|
+
def activate!
|
450
|
+
# add the data/ directory
|
451
|
+
register_data_dir(@data_dir) if File.directory?(@data_dir)
|
452
|
+
|
453
|
+
if File.directory?(@lib_dir)
|
454
|
+
$LOAD_PATH << @lib_dir unless $LOAD_PATH.include?(@lib_dir)
|
455
|
+
end
|
456
|
+
|
457
|
+
# load the lib/init.rb file
|
458
|
+
init_path = self.path.join(LIB_DIR,INIT_FILE)
|
459
|
+
require init_path if init_path.file?
|
460
|
+
|
461
|
+
@activated = true
|
462
|
+
return true
|
463
|
+
end
|
464
|
+
|
465
|
+
#
|
466
|
+
# De-activates the repository by removing the {#lib_dir} from the
|
467
|
+
# `$LOAD_PATH` global variable.
|
468
|
+
#
|
469
|
+
def deactivate!
|
470
|
+
unregister_data_dirs!
|
471
|
+
|
472
|
+
$LOAD_PATH.delete(@lib_dir)
|
473
|
+
|
474
|
+
@activated = false
|
475
|
+
return true
|
476
|
+
end
|
477
|
+
|
478
|
+
#
|
479
|
+
# Clears the {#cached_files} and re-saves the cached files within the
|
480
|
+
# `cache/` directory.
|
481
|
+
#
|
482
|
+
# @return [Repository]
|
483
|
+
# The cleaned repository.
|
484
|
+
#
|
485
|
+
# @since 1.0.0
|
486
|
+
#
|
487
|
+
def cache_files!
|
488
|
+
clean_cached_files!
|
489
|
+
|
490
|
+
cache_paths.each do |path|
|
491
|
+
self.cached_files.new(:path => path).cache
|
492
|
+
end
|
493
|
+
|
494
|
+
return self
|
495
|
+
end
|
496
|
+
|
497
|
+
#
|
498
|
+
# Syncs the {#cached_files} of the repository, and adds any new cached
|
499
|
+
# files.
|
500
|
+
#
|
501
|
+
# @return [Repository]
|
502
|
+
# The cleaned repository.
|
503
|
+
#
|
504
|
+
# @since 1.0.0
|
505
|
+
#
|
506
|
+
def sync_cached_files!
|
507
|
+
# activates the repository before caching it's objects
|
508
|
+
activate!
|
509
|
+
|
510
|
+
new_paths = cache_paths
|
511
|
+
|
512
|
+
self.cached_files.each do |cached_file|
|
513
|
+
# filter out pre-existing paths within the `cached/` directory
|
514
|
+
new_paths.delete(cached_file.path)
|
515
|
+
|
516
|
+
# sync the cached file and catch any exceptions
|
517
|
+
cached_file.sync
|
518
|
+
end
|
519
|
+
|
520
|
+
# cache the new paths within the `cache/` directory
|
521
|
+
new_paths.each do |path|
|
522
|
+
self.cached_files.new(:path => path).cache
|
523
|
+
end
|
524
|
+
|
525
|
+
# deactivates the repository
|
526
|
+
deactivate!
|
527
|
+
|
528
|
+
return self
|
529
|
+
end
|
530
|
+
|
531
|
+
#
|
532
|
+
# Deletes any {#cached_files} associated with the repository.
|
533
|
+
#
|
534
|
+
# @return [Repository]
|
535
|
+
# The cleaned repository.
|
536
|
+
#
|
537
|
+
# @since 1.0.0
|
538
|
+
#
|
539
|
+
def clean_cached_files!
|
540
|
+
self.cached_files.clear
|
541
|
+
return self
|
542
|
+
end
|
543
|
+
|
544
|
+
#
|
545
|
+
# Updates the repository, reloads it's metadata and syncs the
|
546
|
+
# cached files of the repository.
|
547
|
+
#
|
548
|
+
# @yield [repo]
|
549
|
+
# If a block is given, it will be passed after the repository has
|
550
|
+
# been updated.
|
551
|
+
#
|
552
|
+
# @yieldparam [Repository] repo
|
553
|
+
# The updated repository.
|
554
|
+
#
|
555
|
+
# @return [Repository]
|
556
|
+
# The updated repository.
|
557
|
+
#
|
558
|
+
# @since 1.0.0
|
559
|
+
#
|
560
|
+
def update!
|
561
|
+
local_repo = Pullr::LocalRepository.new(
|
562
|
+
:path => self.path,
|
563
|
+
:scm => self.scm
|
564
|
+
)
|
565
|
+
|
566
|
+
# only update if we have a repository
|
567
|
+
local_repo.update(self.uri)
|
568
|
+
|
569
|
+
# re-initialize the metadata
|
570
|
+
initialize_metadata()
|
571
|
+
|
572
|
+
# save the repository
|
573
|
+
if save
|
574
|
+
# syncs the cached files of the repository
|
575
|
+
sync_cached_files!
|
576
|
+
end
|
577
|
+
|
578
|
+
yield self if block_given?
|
579
|
+
return self
|
580
|
+
end
|
581
|
+
|
582
|
+
#
|
583
|
+
# Deletes the contents of the repository.
|
584
|
+
#
|
585
|
+
# @yield [repo]
|
586
|
+
# If a block is given, it will be passed the repository after it's
|
587
|
+
# contents have been deleted.
|
588
|
+
#
|
589
|
+
# @yieldparam [Repository] repo
|
590
|
+
# The deleted repository.
|
591
|
+
#
|
592
|
+
# @return [Repository]
|
593
|
+
# The deleted repository.
|
594
|
+
#
|
595
|
+
# @since 1.0.0
|
596
|
+
#
|
597
|
+
def uninstall!
|
598
|
+
deactivate!
|
599
|
+
|
600
|
+
FileUtils.rm_rf(self.path) if self.installed?
|
601
|
+
|
602
|
+
# destroy any cached files first
|
603
|
+
clean_cached_files!
|
604
|
+
|
605
|
+
# remove the repository from the database
|
606
|
+
destroy if saved?
|
607
|
+
|
608
|
+
yield self if block_given?
|
609
|
+
return self
|
610
|
+
end
|
611
|
+
|
612
|
+
#
|
613
|
+
# Converts the repository to a String.
|
614
|
+
#
|
615
|
+
# @return [String]
|
616
|
+
# The name and domain of the repository.
|
617
|
+
#
|
618
|
+
def to_s
|
619
|
+
"#{self.name}/#{self.domain}"
|
620
|
+
end
|
621
|
+
|
622
|
+
protected
|
623
|
+
|
624
|
+
#
|
625
|
+
# Loads the metadata from {METADATA_FILE} within the repository.
|
626
|
+
#
|
627
|
+
def initialize_metadata
|
628
|
+
metadata_path = self.path.join(METADATA_FILE)
|
629
|
+
|
630
|
+
self.title = self.name
|
631
|
+
self.description = nil
|
632
|
+
self.license = nil
|
633
|
+
|
634
|
+
self.source = self.uri
|
635
|
+
self.website = self.source
|
636
|
+
self.authors.clear
|
637
|
+
|
638
|
+
if File.file?(metadata_path)
|
639
|
+
metadata = YAML.load_file(metadata_path)
|
640
|
+
|
641
|
+
if (title = metadata['title'])
|
642
|
+
self.title = title
|
643
|
+
end
|
644
|
+
|
645
|
+
if (description = metadata['description'])
|
646
|
+
self.description = description
|
647
|
+
end
|
648
|
+
|
649
|
+
if (license = metadata['license'])
|
650
|
+
self.license = License.predefined_resource_with(:name => license)
|
651
|
+
end
|
652
|
+
|
653
|
+
if (uri = metadata['uri'])
|
654
|
+
self.uri ||= uri
|
655
|
+
end
|
656
|
+
|
657
|
+
if (source = metadata['source'])
|
658
|
+
self.source = source
|
659
|
+
end
|
660
|
+
|
661
|
+
if (website = metadata['website'])
|
662
|
+
self.website = website
|
663
|
+
end
|
664
|
+
|
665
|
+
case metadata['authors']
|
666
|
+
when Hash
|
667
|
+
metadata['authors'].each do |name,email|
|
668
|
+
self.authors << Author.first_or_new(:name => name, :email => email)
|
669
|
+
end
|
670
|
+
when Array
|
671
|
+
metadata['authors'].each do |name|
|
672
|
+
self.authors << Author.first_or_new(:name => name)
|
673
|
+
end
|
674
|
+
end
|
675
|
+
end
|
676
|
+
|
677
|
+
return self
|
678
|
+
end
|
679
|
+
|
680
|
+
end
|
681
|
+
end
|
data/lib/ronin/ronin.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#
|
2
|
+
# Ronin - A Ruby platform for exploit development and security research.
|
3
|
+
#
|
4
|
+
# Copyright (c) 2006-2010 Hal Brodigan (postmodern.mod3 at gmail.com)
|
5
|
+
#
|
6
|
+
# This program is free software; you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation; either version 2 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with this program; if not, write to the Free Software
|
18
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
19
|
+
#
|
20
|
+
|
21
|
+
require 'ronin/class_methods'
|
22
|
+
|
23
|
+
require 'open_namespace'
|
24
|
+
|
25
|
+
module Ronin
|
26
|
+
include OpenNamespace
|
27
|
+
|
28
|
+
def self.included(base)
|
29
|
+
base.send :extend, ClassMethods
|
30
|
+
end
|
31
|
+
end
|