audits1984 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +64 -0
  4. data/Rakefile +18 -0
  5. data/app/assets/config/audits1984_manifest.js +2 -0
  6. data/app/assets/javascripts/audits1984/application.js +3 -0
  7. data/app/assets/stylesheets/audits1984/application.css +15 -0
  8. data/app/assets/stylesheets/audits1984/forms.scss +3 -0
  9. data/app/assets/stylesheets/audits1984/sessions.scss +7 -0
  10. data/app/controllers/audits1984/application_controller.rb +18 -0
  11. data/app/controllers/audits1984/audits_controller.rb +43 -0
  12. data/app/controllers/audits1984/filtered_sessions_controller.rb +15 -0
  13. data/app/controllers/audits1984/filtered_sessions_scoped.rb +14 -0
  14. data/app/controllers/audits1984/sessions_controller.rb +16 -0
  15. data/app/helpers/audits1984/application_helper.rb +30 -0
  16. data/app/jobs/audits1984/application_job.rb +4 -0
  17. data/app/mailers/audits1984/application_mailer.rb +6 -0
  18. data/app/models/audits1984/application_record.rb +5 -0
  19. data/app/models/audits1984/audit.rb +10 -0
  20. data/app/models/audits1984/current.rb +3 -0
  21. data/app/models/audits1984/filtered_sessions.rb +30 -0
  22. data/app/models/audits1984/session/auditable.rb +13 -0
  23. data/app/models/audits1984/session/iterable.rb +23 -0
  24. data/app/views/audits1984/sessions/_audit_form.html.erb +26 -0
  25. data/app/views/audits1984/sessions/_executed_code.html.erb +26 -0
  26. data/app/views/audits1984/sessions/_filter.html.erb +34 -0
  27. data/app/views/audits1984/sessions/_header.html.erb +14 -0
  28. data/app/views/audits1984/sessions/_session.html.erb +25 -0
  29. data/app/views/audits1984/sessions/_summary.html.erb +5 -0
  30. data/app/views/audits1984/sessions/index.html.erb +8 -0
  31. data/app/views/audits1984/sessions/show.html.erb +10 -0
  32. data/app/views/layouts/audits1984/_flash.html.erb +10 -0
  33. data/app/views/layouts/audits1984/application.html.erb +24 -0
  34. data/config/routes.rb +9 -0
  35. data/db/migrate/20210810092639_create_auditing_tables.rb +12 -0
  36. data/lib/audits1984.rb +11 -0
  37. data/lib/audits1984/engine.rb +25 -0
  38. data/lib/audits1984/version.rb +3 -0
  39. data/lib/tasks/audits1984_tasks.rake +4 -0
  40. metadata +266 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3a9311c9ec3963b621a59b27ade63d08fc437e1e3c4592328f1b605a7b9efa36
4
+ data.tar.gz: b3929c49492a35f549e5e694757e45128f2cd76dfbd1ac544de8fd5a491b395a
5
+ SHA512:
6
+ metadata.gz: b714c33110ba010483c87d9d676bfea74f06a21fd351f9a1d64c3e59096a4d01f8380f465b1a74f8660912c1028041e32a9847eaf04a92eab3d45729d0029d31
7
+ data.tar.gz: 4b89ad3603f65d9490a315a62d2b0d736a98b22ffa8b11df16c4609df5594db591a467c0ef1eb7d645bf277609df22fb28440b9a9d346878e3c244a09576ce0c
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2021 Jorge Manrubia
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,64 @@
1
+ ![example workflow](https://github.com/basecamp/audits1984/actions/workflows/build.yml/badge.svg)
2
+
3
+ # Audits1984
4
+
5
+ A simple auditing tool for [`console1984`](https://github.com/basecamp/console1984).
6
+
7
+
8
+
9
+ ## Installation
10
+
11
+ Add it to your `Gemfile`:
12
+
13
+ ```ruby
14
+ gem 'audits1984'
15
+ ```
16
+
17
+ Create tables to store audits in the database:
18
+
19
+ ```ruby
20
+ rails audits1984:install:migrations
21
+ rails db:migrate
22
+ ```
23
+
24
+ Mount the engine in your `routes.rb`:
25
+
26
+ ```ruby
27
+ mount Audits1984::Engine => "/console"
28
+ ```
29
+
30
+ ### Authenticate auditors
31
+
32
+ By default, the library controllers will inherit from the host application's `ApplicationController`. To authenticate auditors, you need to implement a method `#find_current_auditor` in your `ApplicationController`. This method must return a record representing the auditing user. It can be any model but it has to respond to `#name`.
33
+
34
+ For example, Imagine all the staff in your company can audit console sessions:
35
+
36
+ ```ruby
37
+ def find_current_auditor
38
+ Current.user if Current.user&.staff?
39
+ end
40
+ ```
41
+
42
+ ## Usage
43
+
44
+ The main screen lists the registered console sessions. It includes a form to filter sessions by date, and also to only show that contains sensitive accesses.
45
+
46
+ ![Main screen listing the registered console sessions with a filter form](docs/images/main-screen.png)
47
+
48
+ You can click on a session to see its commands and choose whether it was an appropiate console usage or not.
49
+
50
+ ![Audit session screen](docs/images/audit-session-screen.png)
51
+
52
+ After making a decision on the session, you will be redirected to the next pending session, based on the filter configured in the main screen.
53
+
54
+ That is. I said it was simple.
55
+
56
+ ## Configuration
57
+
58
+ These config options are namespaced in `config.audits1984`:
59
+
60
+ | Name | Description |
61
+ | --------------------- | ------------------------------------------------------------ |
62
+ | auditor_class | The name of the auditor class. By default it's `::User.` |
63
+ | base_controller_class | The host application base class that will be the parent of `audit1984` controllers. By default it's `::ApplicationController`. |
64
+
data/Rakefile ADDED
@@ -0,0 +1,18 @@
1
+ require "bundler/setup"
2
+
3
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
4
+ load "rails/tasks/engine.rake"
5
+
6
+ load "rails/tasks/statistics.rake"
7
+
8
+ require "bundler/gem_tasks"
9
+
10
+ require "rake/testtask"
11
+
12
+ Rake::TestTask.new(:test) do |t|
13
+ t.libs << 'test'
14
+ t.pattern = 'test/**/*_test.rb'
15
+ t.verbose = false
16
+ end
17
+
18
+ task default: :test
@@ -0,0 +1,2 @@
1
+ //= link_directory ../stylesheets/audits1984 .css
2
+ //= link_directory ../javascripts/audits1984 .js
@@ -0,0 +1,3 @@
1
+ //= include turbo
2
+
3
+ //= require_directory .
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,3 @@
1
+ form {
2
+ width: 100%;
3
+ }
@@ -0,0 +1,7 @@
1
+ .sessions {
2
+ .session {
3
+ color: initial;
4
+ padding: 0.5rem 0;
5
+ border-bottom: 1px solid rgba(128,128,128,0.32);
6
+ }
7
+ }
@@ -0,0 +1,18 @@
1
+ module Audits1984
2
+ class ApplicationController < Audits1984.base_controller_class.constantize
3
+ before_action :authenticate_auditor
4
+
5
+ layout "audits1984/application"
6
+
7
+ private
8
+ def authenticate_auditor
9
+ unless respond_to?(:find_current_auditor, true)
10
+ raise NotImplementedError, "Base controller class '#{Audits1984.base_controller_class}' must implement \#find_current_auditor'"
11
+ end
12
+
13
+ unless Current.auditor = find_current_auditor
14
+ head :forbidden
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,43 @@
1
+ require_dependency "audits1984/application_controller"
2
+
3
+ module Audits1984
4
+ class AuditsController < ApplicationController
5
+ include FilteredSessionsScoped
6
+
7
+ before_action :set_session
8
+ before_action :set_audit, only: %i[ update ]
9
+
10
+ def create
11
+ @audit = @session.audits.create!(audit_param.merge(auditor: Current.auditor))
12
+ redirect_to_next_session
13
+ end
14
+
15
+ def update
16
+ @audit.update!(audit_param)
17
+ redirect_to_next_session
18
+ end
19
+
20
+ private
21
+ def set_session
22
+ @session = Console1984::Session.find(params[:session_id])
23
+ end
24
+
25
+ def set_audit
26
+ @audit = @session.audits.find(params[:id])
27
+ end
28
+
29
+ def audit_param
30
+ params.require(:audit).permit(:notes, :status)
31
+ end
32
+
33
+ def redirect_to_next_session
34
+ next_path = if next_session = @filtered_sessions.pending_session_after(@session)
35
+ next_session
36
+ else
37
+ sessions_path
38
+ end
39
+
40
+ redirect_to next_path, notice: "Session #{@session.id} was #{@audit.status}"
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,15 @@
1
+ require_dependency "audits1984/application_controller"
2
+
3
+ module Audits1984
4
+ class FilteredSessionsController < ApplicationController
5
+ def update
6
+ session[:filtered_sessions] = Audits1984::FilteredSessions.new(filtered_sessions_param).to_h
7
+ redirect_to sessions_path
8
+ end
9
+
10
+ private
11
+ def filtered_sessions_param
12
+ params.require(:filtered_sessions).permit(:sensitive_only, :from_date, :to_date)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,14 @@
1
+ module Audits1984
2
+ module FilteredSessionsScoped
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ before_action :set_filtered_sessions
7
+ end
8
+
9
+ private
10
+ def set_filtered_sessions
11
+ @filtered_sessions = Audits1984::FilteredSessions.resume(session[:filtered_sessions])
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,16 @@
1
+ require_dependency "audits1984/application_controller"
2
+
3
+ module Audits1984
4
+ class SessionsController < ApplicationController
5
+ include FilteredSessionsScoped
6
+
7
+ def index
8
+ @sessions = @filtered_sessions.all
9
+ end
10
+
11
+ def show
12
+ @session = Console1984::Session.find(params[:id])
13
+ @audit = @session.audits.find_by(auditor: Current.auditor) || @session.audits.build(auditor: Current.auditor)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,30 @@
1
+ require "rouge"
2
+ require "rails_rinku"
3
+
4
+ module Audits1984
5
+ module ApplicationHelper
6
+ def format_date(date)
7
+ # <time datetime="2016-1-1">11:09 PM - 1 Jan 2016</time>
8
+ date.strftime("%Y-%m-%d")
9
+ end
10
+
11
+ def format_date_and_time(date)
12
+ # <time datetime="2016-1-1">11:09 PM - 1 Jan 2016</time>
13
+ date.strftime("%Y-%m-%d at %I:%m %P")
14
+ end
15
+
16
+ def highlighted_code_from(commands)
17
+ highlight_code commands.collect(&:statements).collect(&:strip).filter(&:present?).join("\n")
18
+ end
19
+
20
+ def highlight_code(source)
21
+ formatter = Rouge::Formatters::HTMLLinewise.new(Rouge::Formatters::HTML.new)
22
+ lexer = Rouge::Lexers::Ruby.new
23
+ formatter.format(lexer.lex(source)).html_safe
24
+ end
25
+
26
+ def sensitive_session_decoration(session)
27
+ "*" if session.sensitive?
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,4 @@
1
+ module Audits1984
2
+ class ApplicationJob < ActiveJob::Base
3
+ end
4
+ end
@@ -0,0 +1,6 @@
1
+ module Audits1984
2
+ class ApplicationMailer < ActionMailer::Base
3
+ default from: "from@example.com"
4
+ layout "mailer"
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module Audits1984
2
+ class ApplicationRecord < ActiveRecord::Base
3
+ self.abstract_class = true
4
+ end
5
+ end
@@ -0,0 +1,10 @@
1
+ module Audits1984
2
+ class Audit < Console1984::Base
3
+ belongs_to :session, class_name: "Console1984::Session", touch: true
4
+ belongs_to :auditor, class_name: Audits1984.auditor_class
5
+
6
+ enum status: %i[ pending approved flagged ]
7
+
8
+ encrypts :notes
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ class Audits1984::Current < ActiveSupport::CurrentAttributes
2
+ attribute :auditor
3
+ end
@@ -0,0 +1,30 @@
1
+ module Audits1984
2
+ class FilteredSessions
3
+ include ActiveModel::Model
4
+ include ActiveModel::Attributes
5
+
6
+ attribute :from_date, :date
7
+ attribute :to_date, :date
8
+ attribute :sensitive_only, :boolean
9
+
10
+ def self.resume(attributes)
11
+ new attributes&.with_indifferent_access&.slice(*attribute_names)
12
+ end
13
+
14
+ def to_h
15
+ attributes.compact.transform_values(&:to_s)
16
+ end
17
+
18
+ def all
19
+ sessions = Console1984::Session.order(created_at: :desc, id: :desc)
20
+ sessions = sessions.sensitive if sensitive_only
21
+ sessions = sessions.where("console1984_sessions.created_at >= ?", from_date.beginning_of_day) if from_date.present?
22
+ sessions = sessions.where("console1984_sessions.created_at <= ?", to_date.end_of_day) if to_date.present?
23
+ sessions
24
+ end
25
+
26
+ def pending_session_after(session)
27
+ all.pending.where("console1984_sessions.created_at < ? OR console1984_sessions.id < ?", session.created_at, session.id).first
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,13 @@
1
+ module Audits1984::Session::Auditable
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ has_many :audits, dependent: :destroy, class_name: "Audits1984::Audit"
6
+
7
+ scope :sensitive, -> { joins(:sensitive_accesses).distinct }
8
+ scope :reviewed, -> { joins(:audits).distinct }
9
+ scope :approved, -> { reviewed.where("audits.status": :approved) }
10
+ scope :flagged, -> { reviewed.where("audits.status": :flagged) }
11
+ scope :pending, -> { where.not(id: reviewed) }
12
+ end
13
+ end
@@ -0,0 +1,23 @@
1
+ module Audits1984::Session::Iterable
2
+ extend ActiveSupport::Concern
3
+
4
+ # Loops through all the session commands in order, yielding lists grouped by
5
+ # its sensitive access record, or its absence
6
+ def each_batch_of_commands_grouped_by_sensitive_access
7
+ group = []
8
+ current_sensitive_access = nil
9
+ commands.includes(:sensitive_access).sorted_chronologically.each.with_index do |command, index|
10
+ current_sensitive_access = command.sensitive_access if index == 0
11
+ if index > 0 && command.sensitive_access != current_sensitive_access
12
+ yield current_sensitive_access, group
13
+ group = []
14
+ current_sensitive_access = command.sensitive_access
15
+ end
16
+ group << command
17
+ end
18
+
19
+ if group.present?
20
+ yield current_sensitive_access, group
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,26 @@
1
+ <article class="panel mt-5">
2
+ <p class="panel-heading">
3
+ Your review
4
+ </p>
5
+
6
+ <div class="panel-block">
7
+ <%= form_with model: [session, audit], authenticity_token: true do |form| %>
8
+ <div class="field">
9
+ <div class="control is-fullwidth">
10
+ <%= form.label :from_date, "Notes" %>
11
+ <%= form.text_area :notes, class: "textarea", placeholder: "Enter optional comments..." %>
12
+ </div>
13
+ </div>
14
+ <div class="field is-grouped">
15
+ <div class="control">
16
+ <%= form.button name: "audit[status]", value: :approved, class: "button is-primary" do %>
17
+ Approve
18
+ <% end %>
19
+ <%= form.button name: "audit[status]", value: :flagged, class: "button is-danger" do %>
20
+ Flag as inappropriate
21
+ <% end %>
22
+ </div>
23
+ </div>
24
+ <% end %>
25
+ </div>
26
+ </article>
@@ -0,0 +1,26 @@
1
+ <style>
2
+ <%= Rouge::Theme.find('github').render(scope: '.highlight') %>
3
+ </style>
4
+
5
+ <% session.each_batch_of_commands_grouped_by_sensitive_access do |sensitive_access, commands| %>
6
+ <div class="card">
7
+ <div class="card-content">
8
+ <div class="media">
9
+ <div class="media-content">
10
+ <% if sensitive_access %>
11
+ <p class="title is-4">Sensitive access *</p>
12
+ <p class="subtitle is-6"><%= auto_link(sensitive_access.justification) %></p>
13
+ <% else %>
14
+ <p class="title is-4">Protected access</p>
15
+ <% end %>
16
+ </div>
17
+ </div>
18
+
19
+ <div class="content">
20
+ <pre class="highlight">
21
+ <%= highlighted_code_from commands %>
22
+ </pre>
23
+ </div>
24
+ </div>
25
+ </div>
26
+ <% end %>
@@ -0,0 +1,34 @@
1
+ <nav class="panel">
2
+ <p class="panel-heading">
3
+ Filter console sessions
4
+ </p>
5
+ <div class="panel-block">
6
+
7
+ <%= form_with model: filtered_sessions, url: filtered_sessions_path, method: :put, authenticity_token: true do |form| %>
8
+ <div class="field is-grouped">
9
+ <div class="control">
10
+ <%= form.label :from_date, "From" %>
11
+ <%= form.date_field :from_date, class: "input" %>
12
+ </div>
13
+
14
+ <div class="control">
15
+ <%= form.label :to_date, "To" %>
16
+ <%= form.date_field :to_date, class: "input" %>
17
+ </div>
18
+ </div>
19
+
20
+ <div class="field">
21
+ <div class="control">
22
+ <%= form.label :sensitive_only, "Only with sensitive access", class: "checkbox" %>
23
+ <%= form.check_box :sensitive_only %>
24
+ </div>
25
+ </div>
26
+
27
+ <div class="field is-grouped">
28
+ <div class="control">
29
+ <%= form.submit "Filter", class: "button is-link" %>
30
+ </div>
31
+ </div>
32
+ <% end %>
33
+ </div>
34
+ </nav>
@@ -0,0 +1,14 @@
1
+ <h2 class="title"><%= auto_link(session.reason) %> <%= sensitive_session_decoration(session) %></h2>
2
+ <h3 class="subtitle">by <%= session.user.username %>
3
+ <br> <%= format_date_and_time(session.created_at) %></h3>
4
+
5
+ <% if session.audits.any? %>
6
+ <ul class="mb-6">
7
+ <% session.audits.except(&:new_record?).each do |audit| %>
8
+ <li> <%= audit.status.humanize %>
9
+ by <%= audit.auditor == Audits1984::Current.auditor ? "You" : audit.auditor.name %>
10
+ on <%= format_date_and_time(audit.created_at) %>
11
+ </li>
12
+ <% end %>
13
+ </ul>
14
+ <% end %>
@@ -0,0 +1,25 @@
1
+ <%= link_to session_path(session) do %>
2
+ <article class="session media">
3
+ <div class="media-left">
4
+ <%= format_date session.created_at %>
5
+ </div>
6
+ <div class="media-content">
7
+ <div class="content">
8
+ <p>
9
+ <strong class="session__reason"><%= session.reason %></strong>
10
+ <%= sensitive_session_decoration(session) %>
11
+ <br>
12
+ by <%= session.user.username %>
13
+ </p>
14
+ </div>
15
+ </div>
16
+
17
+ <div class="session__status media-right">
18
+ <% if session.audits.any? %>
19
+ <%= session.audits.pluck(:status).collect(&:humanize).join(", ") %>
20
+ <% else %>
21
+ Pending
22
+ <% end %>
23
+ </div>
24
+ </article>
25
+ <% end %>
@@ -0,0 +1,5 @@
1
+ <article class="message is-info">
2
+ <div class="message-body">
3
+ <%= sessions.count %> sessions (<%= sessions.pending.count %> pending, <%= sessions.approved.count %> approved, <%= sessions.flagged.count %> flagged)
4
+ </div>
5
+ </article>
@@ -0,0 +1,8 @@
1
+ <%= render "audits1984/sessions/filter", filtered_sessions: @filtered_sessions %>
2
+ <%= render "audits1984/sessions/summary", sessions: @sessions %>
3
+
4
+ <turbo-frame id="sessions">
5
+ <div class="sessions">
6
+ <%= render partial: "audits1984/sessions/session", collection: @sessions, cached: true %>
7
+ </div>
8
+ </turbo-frame>
@@ -0,0 +1,10 @@
1
+ <nav class="breadcrumb">
2
+ <ul>
3
+ <li><%= link_to "Sessions", sessions_path %></li>
4
+ <li class="is-active"><a href="#" aria-current="page">Session <%= @session.id %> by <%= @session.user.username %></a></li>
5
+ </ul>
6
+ </nav>
7
+
8
+ <%= render "audits1984/sessions/header", session: @session, audit: @audit %>
9
+ <%= render "audits1984/sessions/executed_code", session: @session %>
10
+ <%= render "audits1984/sessions/audit_form", session: @session, audit: @audit %>
@@ -0,0 +1,10 @@
1
+ <% flash.each do |name, message| -%>
2
+ <% message_class = { notice: "is-success", alert: "is-danger" }[name.to_sym] %>
3
+
4
+ <article class="message <%= message_class %>">
5
+ <div class="message-body">
6
+ <%= message %>
7
+ </div>
8
+ </article>
9
+
10
+ <% end -%>
@@ -0,0 +1,24 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title><%= @title || "Audits1984" %></title>
6
+ <meta name="viewport" content="width=device-width, initial-scale=1">
7
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.3/css/bulma.min.css">
8
+
9
+ <%= csrf_meta_tags %>
10
+
11
+ <%= javascript_include_tag "audits1984/application", data: { turbo_track: :reload } %>
12
+ <%= stylesheet_link_tag "audits1984/application", media: :all, data: { turbo_track: :reload } %>
13
+ </head>
14
+
15
+ <body>
16
+
17
+ <section class="section">
18
+ <div class="container">
19
+ <%= render "layouts/audits1984/flash" %>
20
+ <%= yield %>
21
+ </div>
22
+ </section>
23
+ </body>
24
+ </html>
data/config/routes.rb ADDED
@@ -0,0 +1,9 @@
1
+ Audits1984::Engine.routes.draw do
2
+ resources :sessions, only: %i[ index show ] do
3
+ resources :audits, only: %i[ create update ]
4
+ end
5
+
6
+ resource :filtered_sessions, only: %i[ update ]
7
+
8
+ root to: "sessions#index"
9
+ end
@@ -0,0 +1,12 @@
1
+ class CreateAuditingTables < ActiveRecord::Migration[7.0]
2
+ def change
3
+ create_table :audits1984_audits do |t|
4
+ t.integer :status, default: 0, null: false
5
+ t.text :notes
6
+ t.references :session, null: false
7
+ t.references :auditor, null: false
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
data/lib/audits1984.rb ADDED
@@ -0,0 +1,11 @@
1
+ require "audits1984/version"
2
+ require "audits1984/engine"
3
+
4
+ require "zeitwerk"
5
+ loader = Zeitwerk::Loader.for_gem
6
+ loader.setup
7
+
8
+ module Audits1984
9
+ mattr_accessor :auditor_class, default: "::User"
10
+ mattr_accessor :base_controller_class, default: "::ApplicationController"
11
+ end
@@ -0,0 +1,25 @@
1
+ require "console1984"
2
+
3
+ module Audits1984
4
+ class Engine < ::Rails::Engine
5
+ isolate_namespace Audits1984
6
+
7
+ config.audits1984 = ActiveSupport::OrderedOptions.new
8
+
9
+ initializer "audits1984.config" do
10
+ config.audits1984.each do |key, value|
11
+ Audits1984.send("#{key}=", value)
12
+ end
13
+ end
14
+
15
+ initializer "audits1984.session" do
16
+ ActiveSupport.on_load(:console_1984_session) do
17
+ include Audits1984::Session::Auditable, Audits1984::Session::Iterable
18
+ end
19
+ end
20
+
21
+ initializer "audits1984.assets.precompile" do |app|
22
+ app.config.assets.precompile << "audits1984_manifest.js"
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,3 @@
1
+ module Audits1984
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :audits1984 do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,266 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: audits1984
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jorge Manrubia
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-08-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rouge
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: turbo-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sassc-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rinku
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: console1984
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 1.18.4
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 1.18.4
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop-performance
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop-minitest
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop-packaging
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop-rails
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: capybara
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: selenium-webdriver
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: puma
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ description: Rails engine that implements a simple auditing tool for console1984 sessions
196
+ email:
197
+ - jorge.manrubia@gmail.com
198
+ executables: []
199
+ extensions: []
200
+ extra_rdoc_files: []
201
+ files:
202
+ - MIT-LICENSE
203
+ - README.md
204
+ - Rakefile
205
+ - app/assets/config/audits1984_manifest.js
206
+ - app/assets/javascripts/audits1984/application.js
207
+ - app/assets/stylesheets/audits1984/application.css
208
+ - app/assets/stylesheets/audits1984/forms.scss
209
+ - app/assets/stylesheets/audits1984/sessions.scss
210
+ - app/controllers/audits1984/application_controller.rb
211
+ - app/controllers/audits1984/audits_controller.rb
212
+ - app/controllers/audits1984/filtered_sessions_controller.rb
213
+ - app/controllers/audits1984/filtered_sessions_scoped.rb
214
+ - app/controllers/audits1984/sessions_controller.rb
215
+ - app/helpers/audits1984/application_helper.rb
216
+ - app/jobs/audits1984/application_job.rb
217
+ - app/mailers/audits1984/application_mailer.rb
218
+ - app/models/audits1984/application_record.rb
219
+ - app/models/audits1984/audit.rb
220
+ - app/models/audits1984/current.rb
221
+ - app/models/audits1984/filtered_sessions.rb
222
+ - app/models/audits1984/session/auditable.rb
223
+ - app/models/audits1984/session/iterable.rb
224
+ - app/views/audits1984/sessions/_audit_form.html.erb
225
+ - app/views/audits1984/sessions/_executed_code.html.erb
226
+ - app/views/audits1984/sessions/_filter.html.erb
227
+ - app/views/audits1984/sessions/_header.html.erb
228
+ - app/views/audits1984/sessions/_session.html.erb
229
+ - app/views/audits1984/sessions/_summary.html.erb
230
+ - app/views/audits1984/sessions/index.html.erb
231
+ - app/views/audits1984/sessions/show.html.erb
232
+ - app/views/layouts/audits1984/_flash.html.erb
233
+ - app/views/layouts/audits1984/application.html.erb
234
+ - config/routes.rb
235
+ - db/migrate/20210810092639_create_auditing_tables.rb
236
+ - lib/audits1984.rb
237
+ - lib/audits1984/engine.rb
238
+ - lib/audits1984/version.rb
239
+ - lib/tasks/audits1984_tasks.rake
240
+ homepage: https://github.com/basecamp/audits1984
241
+ licenses:
242
+ - MIT
243
+ metadata:
244
+ allowed_push_host: https://rubygems.org
245
+ homepage_uri: https://github.com/basecamp/audits1984
246
+ source_code_uri: https://github.com/basecamp/audits1984
247
+ post_install_message:
248
+ rdoc_options: []
249
+ require_paths:
250
+ - lib
251
+ required_ruby_version: !ruby/object:Gem::Requirement
252
+ requirements:
253
+ - - ">="
254
+ - !ruby/object:Gem::Version
255
+ version: '0'
256
+ required_rubygems_version: !ruby/object:Gem::Requirement
257
+ requirements:
258
+ - - ">="
259
+ - !ruby/object:Gem::Version
260
+ version: '0'
261
+ requirements: []
262
+ rubygems_version: 3.1.4
263
+ signing_key:
264
+ specification_version: 4
265
+ summary: A simple auditing tool for console1984
266
+ test_files: []