Code Monkey home page Code Monkey logo

ronin-db-activerecord's Introduction

ronin-db-activerecord

CI Code Climate Gem Version

Description

ronin-db-activerecord contains ActiveRecord models and migrations for the Ronin Database. Provides database models storing and querying network data, advisory data, credentials, and OSINT data.

Features

Examples

Create a database:

require 'ronin/db/migrations'

ActiveRecord::Base.establish_connection(
  adapter: 'sqlite3',
  database: 'path/to/db.sqlite3'
)

Ronin::DB::Migrations.up

Connect to the database:

ActiveRecord::Base.establish_connection(
  adapter: 'sqlite3',
  database: 'path/to/db.sqlite3'
)

require 'ronin/db/models'
Ronin::DB::Models.connect

Requirements

Install

$ gem install ronin-db-activerecord

Gemfile

gem 'ronin-db-activerecord', '~> 0.1'

gemspec

gem.add_dependency 'ronin-db-activerecord', '~> 0.1'

Development

  1. Fork It!
  2. Clone It!
  3. cd ronin-db-activerecord/
  4. bundle install
  5. git checkout -b my_feature
  6. Code It!
  7. bundle exec rake spec
  8. git push origin my_feature

If you want to test your changes locally, run rake db:console to start a local database console.

License

Copyright (c) 2022-2024 Hal Brodigan ([email protected])

ronin-db-activerecord is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

ronin-db-activerecord is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with ronin-db-activerecord. If not, see https://www.gnu.org/licenses/.

ronin-db-activerecord's People

Contributors

ai-mozi avatar postmodern avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ronin-db-activerecord's Issues

Add a `Note` model

Add a Note model for associating arbitrary text nodes with IPAddresses, HostNames, URLs, etc.

Add models for storing ASN ranges

It must be possible to store and query ASN ranges. Must store the following columns:

  • first_ip / first_ip_uint
  • last_ip / last_ip_uint
  • prefix
  • country_code
  • name

Add custom inflections for acronyms used in model names

Since certain model names contain acronyms, we must configure ActiveSupport::Inflector to preserve them as acronyms instead of converting them to CamelCase when converting the model name into a human readable name:

  • Wrong: IPAddress.model_name.human # => "Ip address"
  • Correct: IPAddress.model_name.human # => "IP address"

Add a `Cert` model

Add a Cert model for storing SSL/TLS certificate information. The model should store the serial number, common_name, and other subject fields. In order to store the data in a normalized fashion, we will also need CertSubject, CertIssuer, and CertSubjectAltName models as well. The Cert module should also have an .import class method which accepts an OpenSSL::X509::Certificate object.

Add missing specs for `URL` query methods

  • URL.http
  • URI.https
  • URL.with_host_name
  • URL.with_port_number
  • URL.with_directory
  • URL.with_ext
  • URL.with_query_param
  • URL.with_query_param_name
  • URL.with_query_param_value
  • URL.find_url

Make `WebCredential` into a join model

Change WebCredential to be a join model between Credential and URL. This will allow associating the same credential pair (ex: user:password or email:password) with multiple URLs.

Make `ServiceCredential` into a join model

Change ServiceCredential to be a join model between Credential and OpenPort. This will allow associating the same credential pair (ex: user:password or email:password) with multiple services.

`URL.import` is not de-duplicating URLs

URL.import is not de-duplicating URLs that are already in the database. This appears to be due to find_or_create_by() not performing the find() query if one of the attributes is an empty Array. The other reason is that SQL UNIQUE INDEXs are not enforced on columns which allow NULL values.

Add rubocop

Add rubocop to the repository.

  • Add the rubocop gem to the Gemfile.
  • Start with the template rubocop.yml file which closely matches Ronin's general code style.
  • Add the rubocop task and add it to the CI.

Re-order the `db/migrate/` migrations

Re-order the db/migrate/ files such that any time a reference is created the referenced table should be created before the migration. This will allow the migrations to run on a PostgreSQL database which requires the referenced table to exist before the reference is created.

Add an ERD diagram based on the models/schema

Generate an ERD diagram based on the models/schema to show the structure of the models/associations. The catch is that this is only a library of ActiveRecord models, so it might be tricky to use existing Rails ERD plugins. YMMV

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.