-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from rahearn/first-feature
First feature
- Loading branch information
Showing
16 changed files
with
129 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,4 +70,5 @@ gem "sidekiq", "~> 7.2" | |
|
||
group :test do | ||
gem "climate_control", "~> 1.0" | ||
gem "shoulda-matchers", "~> 6.2" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
class PagesController < ApplicationController | ||
def home | ||
@documents = Document.all | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class Document < ApplicationRecord | ||
validates_presence_of :title, :url | ||
|
||
validate :url_is_https | ||
|
||
private | ||
|
||
def url_is_https | ||
parsed = URI(url) | ||
errors.add(:url, "must begin with https") unless parsed.scheme == "https" | ||
rescue ArgumentError | ||
errors.add(:url, "must begin with https") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,20 @@ | ||
<h1>Pages#home</h1> | ||
<p>Find me in app/views/pages/home.html.erb</p> | ||
<h1>Published Compliance Documents</h1> | ||
<table class="usa-table"> | ||
<caption> | ||
Component Definitions | ||
</caption> | ||
<thead> | ||
<tr> | ||
<th scope="col">Document title</th> | ||
<th scope="col">Description</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% @documents.each do |d| %> | ||
<tr> | ||
<th scope="row"><%= link_to d.title, d.url, class: "usa-link usa-link--external", rel: "noreferrer", target: "_blank" %></th> | ||
<td><%= d.description %></td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"ignored_warnings": [ | ||
{ | ||
"warning_type": "Cross-Site Scripting", | ||
"warning_code": 4, | ||
"fingerprint": "d0e9d6fdde0767b697aa5a6acefada357aadb15e48d55ce07a17ed87db41e8a6", | ||
"check_name": "LinkToHref", | ||
"message": "Potentially unsafe model attribute in `link_to` href", | ||
"file": "app/views/pages/home.html.erb", | ||
"line": 15, | ||
"link": "https://brakemanscanner.org/docs/warning_types/link_to_href", | ||
"code": "link_to(Document.new.title, Document.new.url, :class => \"usa-link usa-link--external\", :rel => \"noreferrer\", :target => \"_blank\")", | ||
"render_path": [ | ||
{ | ||
"type": "controller", | ||
"class": "PagesController", | ||
"method": "home", | ||
"line": 4, | ||
"file": "app/controllers/pages_controller.rb", | ||
"rendered": { | ||
"name": "pages/home", | ||
"file": "app/views/pages/home.html.erb" | ||
} | ||
} | ||
], | ||
"location": { | ||
"type": "template", | ||
"template": "pages/home" | ||
}, | ||
"user_input": "Document.new.url", | ||
"confidence": "Weak", | ||
"cwe_id": [ | ||
79 | ||
], | ||
"note": "Document#url is validated to only begin with https" | ||
} | ||
], | ||
"updated": "2024-06-25 17:59:19 -0400", | ||
"brakeman_version": "6.1.2" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class CreateDocuments < ActiveRecord::Migration[7.1] | ||
def change | ||
create_table :documents do |t| | ||
t.string :title, null: false | ||
t.text :description, null: false, default: "" | ||
t.string :url, null: false | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe Document, type: :model do | ||
describe "validations" do | ||
it { should validate_presence_of :title } | ||
it { should validate_presence_of :url } | ||
it { should allow_value("https://raw.githubusercontent.com/GSA-TTS/docker-trestle/main/templates/component-definitions/cloud_gov/component-definition.json").for :url } | ||
it { should_not allow_value("javascript:alert('oops')").for :url } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Shoulda::Matchers.configure do |config| | ||
config.integrate do |with| | ||
with.test_framework :rspec | ||
with.library :rails | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters