scaptimony 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +27 -5
- data/app/models/scaptimony/arf_report.rb +48 -1
- data/app/models/scaptimony/arf_report_breakdown.rb +15 -0
- data/app/models/scaptimony/policy.rb +29 -0
- data/app/models/scaptimony/policy_revision.rb +6 -0
- data/app/models/scaptimony/scap_content.rb +108 -0
- data/app/models/scaptimony/scap_content_profile.rb +6 -0
- data/app/models/scaptimony/xccdf_result.rb +7 -0
- data/app/models/scaptimony/xccdf_rule.rb +18 -0
- data/app/models/scaptimony/xccdf_rule_result.rb +11 -0
- data/db/migrate/20141104164201_create_scaptimony_scap_contents.rb +10 -0
- data/db/migrate/20141104171545_create_scaptimony_policy_revisions.rb +14 -0
- data/db/migrate/20141105174625_add_description_to_scaptimony_policy_revisions.rb +5 -0
- data/db/migrate/20141105174834_add_columns_to_scaptimony_policies.rb +12 -0
- data/db/migrate/20141107091756_add_columns_to_scaptimony_scap_contents.rb +8 -0
- data/db/migrate/20141111104519_add_constraint_to_scaptimony_scap_contents.rb +6 -0
- data/db/migrate/20141113221054_create_scaptimony_scap_content_profiles.rb +12 -0
- data/db/migrate/20141116170632_remove_xccdf_profile_from_scaptimony_policies.rb +5 -0
- data/db/migrate/20141116171305_add_profile_to_scaptimony_policies.rb +6 -0
- data/db/migrate/20141118142954_add_constraint_to_scaptimony_policies.rb +5 -0
- data/db/migrate/20141119164918_create_scaptimony_xccdf_results.rb +8 -0
- data/db/migrate/20141119175434_create_scaptimony_xccdf_rules.rb +8 -0
- data/db/migrate/20141119182606_create_scaptimony_xccdf_rule_results.rb +9 -0
- data/db/migrate/20141121120326_create_scaptimony_arf_report_breakdowns.rb +20 -0
- data/db/migrate/20141121164042_replace_arf_report_breakdown_view.rb +20 -0
- data/db/seeds.rb +9 -0
- data/lib/scaptimony/arf_reports_helper.rb +1 -1
- data/lib/scaptimony/engine.rb +4 -0
- data/lib/scaptimony/version.rb +1 -1
- data/test/fixtures/scaptimony/policy_revisions.yml +17 -0
- data/test/fixtures/scaptimony/scap_content_profiles.yml +11 -0
- data/test/fixtures/scaptimony/scap_contents.yml +7 -0
- data/test/fixtures/scaptimony/xccdf_results.yml +7 -0
- data/test/fixtures/scaptimony/xccdf_rule_results.yml +11 -0
- data/test/fixtures/scaptimony/xccdf_rules.yml +7 -0
- data/test/models/scaptimony/arf_report_breakdown_test.rb +9 -0
- data/test/models/scaptimony/policy_revision_test.rb +9 -0
- data/test/models/scaptimony/scap_content_profiles_test.rb +9 -0
- data/test/models/scaptimony/scap_content_test.rb +9 -0
- data/test/models/scaptimony/xccdf_result_test.rb +9 -0
- data/test/models/scaptimony/xccdf_rule_result_test.rb +9 -0
- data/test/models/scaptimony/xccdf_rule_test.rb +9 -0
- metadata +65 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 412955cff2de89a310f911da39fc9cf4d2ac20b3
|
4
|
+
data.tar.gz: d839f32280880847e102a56c9a939d1e296956fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91080cb2eabe76f0038636ed5e0ae8b77374580a4557bd0963c785e222ece1081654856887e669dd59425c5e529d086ac6cd9dc76cd75b37b4c92fde0005561b
|
7
|
+
data.tar.gz: e1aba9516775e5068e43eed1959be8761e027ec9063a76b3a9c3a6b8de63feed1acf413a9675542522e7d980c80ad85e06bea07a741d90b047b5556ebf23e5e4
|
data/README.md
CHANGED
@@ -1,16 +1,36 @@
|
|
1
1
|
# SCAPtimony
|
2
2
|
|
3
|
+
SCAPtimony project gives full testimony about compliance of your infrastructure.
|
3
4
|
SCAPtimony is SCAP storage and database server build on top of OpenSCAP library.
|
4
5
|
SCAPtimony can be deployed as a part of your Rails application (i.e. Foreman) or
|
5
6
|
as a stand-alone sealed server.
|
6
7
|
|
7
8
|
+ Current features:
|
8
|
-
+
|
9
|
-
+
|
9
|
+
+ Achieve SCAP audit results from your infrastructure
|
10
|
+
+ Provide API for tools to upload collected SCAP results
|
11
|
+
+ Define security/compliance policies
|
12
|
+
+ Upload SCAP content and assign it with the policy
|
13
|
+
+ Result post-processing
|
14
|
+
+ Search SCAP results
|
15
|
+
+ Search for non-compliant systems
|
10
16
|
+ Rails artefacts to display audit results within your application
|
11
|
-
|
12
|
-
+
|
13
|
-
|
17
|
+
+ Future features:
|
18
|
+
+ Define security/compliance policies
|
19
|
+
+ Archive distinct versions of the policy
|
20
|
+
+ Set-up a periodical schedule of audits for the policy
|
21
|
+
+ Organization defined targeting (Assign a set of nodes with the policy)
|
22
|
+
+ Define known-issues and waivers (Assign waivers with a set of nodes and the policy)
|
23
|
+
+ Set-up rules for automated deletion of results
|
24
|
+
+ vulnerability assessment (processing OVAL CVE streams)
|
25
|
+
+ Result post-processing
|
26
|
+
+ Search for not audited systems
|
27
|
+
* Comparison of audit results
|
28
|
+
+ Waive known issues
|
29
|
+
+ One time waivers of a report
|
30
|
+
+ Set-up periodic waivers for a given policy and system
|
31
|
+
+ Set a waiver expirations time (to give the time to remediate things)
|
32
|
+
+ Calculate score before and after waiver (ammount of risk accepted needs to be made available to the authorizing official)
|
33
|
+
+ Let us know, if your feature is missing.
|
14
34
|
|
15
35
|
## Installation
|
16
36
|
|
@@ -22,6 +42,8 @@ as a stand-alone sealed server.
|
|
22
42
|
|
23
43
|
- Build SCAPtimony RPM (instructions for Red Hat Enterprise Linux 6)
|
24
44
|
|
45
|
+
Enable Software Collections as per [instructions](https://access.redhat.com/documentation/en-US/Red_Hat_Software_Collections/1/html-single/1.1_Release_Notes/index.html#sect-Installation_and_Usage-Subscribe).
|
46
|
+
|
25
47
|
```
|
26
48
|
$ cd scaptimony
|
27
49
|
$ gem build scaptimony.gemspec
|
@@ -1,16 +1,35 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
require 'openscap'
|
3
3
|
require 'openscap/ds/arf'
|
4
|
+
require 'openscap/xccdf/testresult'
|
5
|
+
require 'openscap/xccdf/ruleresult'
|
6
|
+
require 'scaptimony/engine'
|
4
7
|
|
5
8
|
module Scaptimony
|
6
9
|
class ArfReport < ActiveRecord::Base
|
7
10
|
belongs_to :asset
|
8
11
|
belongs_to :policy
|
12
|
+
has_many :xccdf_rule_results, :dependent => :destroy
|
13
|
+
has_one :arf_report_breakdown
|
14
|
+
|
15
|
+
before_destroy { |record|
|
16
|
+
record.delete
|
17
|
+
}
|
18
|
+
|
19
|
+
scoped_search :on => :date, :complete_value => true
|
20
|
+
scoped_search :in => :arf_report_breakdown, :on => :passed
|
21
|
+
scoped_search :in => :arf_report_breakdown, :on => :failed
|
22
|
+
scoped_search :in => :arf_report_breakdown, :on => :othered
|
23
|
+
|
24
|
+
def passed; arf_report_breakdown ? arf_report_breakdown.passed : 0; end
|
25
|
+
def failed; arf_report_breakdown ? arf_report_breakdown.failed : 0; end
|
26
|
+
def othered; arf_report_breakdown ? arf_report_breakdown.othered : 0; end
|
9
27
|
|
10
28
|
def store!(data)
|
11
29
|
begin
|
12
30
|
FileUtils.mkdir_p dir
|
13
31
|
File.open(path, 'wb') { |f| f.write(data) }
|
32
|
+
save_dependent_entities
|
14
33
|
rescue StandardError => e
|
15
34
|
logger.error "Could not store ARF to '#{path}': #{e.message}"
|
16
35
|
raise e
|
@@ -25,14 +44,42 @@ module Scaptimony
|
|
25
44
|
OpenSCAP.oscap_cleanup
|
26
45
|
end
|
27
46
|
|
47
|
+
def delete
|
48
|
+
File.delete path
|
49
|
+
begin
|
50
|
+
Dir.delete dir
|
51
|
+
rescue StandardError => e
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
28
55
|
private
|
56
|
+
def save_dependent_entities
|
57
|
+
return unless xccdf_rule_results.empty?
|
58
|
+
begin
|
59
|
+
OpenSCAP.oscap_init
|
60
|
+
arf = OpenSCAP::DS::Arf.new path
|
61
|
+
test_result = arf.test_result
|
62
|
+
test_result.rr.each {|rr_id, rr|
|
63
|
+
rule = ::Scaptimony::XccdfRule.where(:xid => rr_id).first_or_create!
|
64
|
+
xccdf_rule_results.create!(:xccdf_rule_id => rule.id, :xccdf_result_id => XccdfResult.f(rr.result).id)
|
65
|
+
}
|
66
|
+
rescue StandardError => e
|
67
|
+
xccdf_rule_results.destroy_all
|
68
|
+
raise e
|
69
|
+
ensure
|
70
|
+
test_result.destroy unless test_result.nil?
|
71
|
+
arf.destroy unless arf.nil?
|
72
|
+
OpenSCAP.oscap_cleanup
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
29
76
|
def path
|
30
77
|
"#{dir}/#{digest}.xml.bz2"
|
31
78
|
end
|
32
79
|
|
33
80
|
def dir
|
34
81
|
# TODO this should be configurable
|
35
|
-
"/
|
82
|
+
"#{Scaptimony::Engine.dir}/arf/#{asset.name}/#{policy.name}/#{date}"
|
36
83
|
end
|
37
84
|
end
|
38
85
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Scaptimony
|
2
|
+
class ArfReportBreakdown < ActiveRecord::Base
|
3
|
+
# This class aggregates counts of xccdf:rule-result by xccdf:result. The columns
|
4
|
+
# (failed, passed, othered) mimics the 'Rule result breakdown' from OpenSCAP HTML
|
5
|
+
# Report.
|
6
|
+
#
|
7
|
+
# Frameworks like scoped_search cannot do group-by, so this is implemented
|
8
|
+
# as a database view.
|
9
|
+
|
10
|
+
set_primary_key :arf_report_id
|
11
|
+
|
12
|
+
protected
|
13
|
+
def readonly?; true end
|
14
|
+
end
|
15
|
+
end
|
@@ -1,4 +1,33 @@
|
|
1
|
+
require 'openscap'
|
2
|
+
require 'openscap/ds/sds'
|
3
|
+
|
1
4
|
module Scaptimony
|
2
5
|
class Policy < ActiveRecord::Base
|
6
|
+
belongs_to :scap_content
|
7
|
+
belongs_to :scap_content_profile
|
8
|
+
has_many :arf_reports, dependent: :destroy
|
9
|
+
|
10
|
+
validates :name, :presence => true
|
11
|
+
end
|
12
|
+
|
13
|
+
class GuideGenerator
|
14
|
+
def initialize(p)
|
15
|
+
case p
|
16
|
+
when Scaptimony::Policy
|
17
|
+
@scap_content = p.scap_content
|
18
|
+
@profile = p.scap_content_profile
|
19
|
+
end
|
20
|
+
if @scap_content.nil? or @scap_content.source.nil?
|
21
|
+
OpenSCAP.raise! "Cannot generate HTML Guide for #{@scap_content}/#{@profile}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def each
|
26
|
+
sds = OpenSCAP::DS::Sds.new @scap_content.source
|
27
|
+
sds.select_checklist
|
28
|
+
profile_id = @profile.nil? ? nil : @profile.profile_id
|
29
|
+
yield sds.html_guide profile_id
|
30
|
+
sds.destroy
|
31
|
+
end
|
3
32
|
end
|
4
33
|
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'digest'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'openscap/ds/sds'
|
4
|
+
require 'openscap/source'
|
5
|
+
require 'openscap/xccdf/benchmark'
|
6
|
+
require 'scaptimony/engine'
|
7
|
+
|
8
|
+
module Scaptimony
|
9
|
+
class DataStreamValidator < ActiveModel::Validator
|
10
|
+
def validate(scap_content)
|
11
|
+
if !scap_content.new_record?
|
12
|
+
return true if scap_content.scap_file.nil?
|
13
|
+
scap_content.errors[:base] << _("Cannot change uploaded file while editing content.")
|
14
|
+
return false
|
15
|
+
end
|
16
|
+
if scap_content.scap_file.nil?
|
17
|
+
scap_content.errors[:base] << _("Please select file for upload.")
|
18
|
+
return false
|
19
|
+
end
|
20
|
+
|
21
|
+
existing = ScapContent.where(:digest => scap_content.digest).first
|
22
|
+
if !existing.nil?
|
23
|
+
scap_content.errors[:base] << _("This file has been already uploaded as '#{existing.title}'.")
|
24
|
+
return false
|
25
|
+
end
|
26
|
+
|
27
|
+
allowed_type = 'SCAP Source Datastream'
|
28
|
+
if scap_content.source.type != allowed_type
|
29
|
+
scap_content.errors[:base] << _("Uploaded file is not #{allowed_type}.")
|
30
|
+
return false
|
31
|
+
end
|
32
|
+
|
33
|
+
begin
|
34
|
+
scap_content.source.validate!
|
35
|
+
rescue OpenSCAP::OpenSCAPError => e
|
36
|
+
scap_content.errors[:base] << e.message
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class ScapContent < ActiveRecord::Base
|
42
|
+
has_many :scap_content_profiles, :dependent => :destroy
|
43
|
+
has_many :policies, :dependent => :destroy
|
44
|
+
|
45
|
+
validates_with Scaptimony::DataStreamValidator
|
46
|
+
validates :title, :presence => true
|
47
|
+
validates :digest, :presence => true
|
48
|
+
attr_accessor :scap_file
|
49
|
+
|
50
|
+
def store
|
51
|
+
if valid_store_attempt
|
52
|
+
begin
|
53
|
+
FileUtils.mkdir_p dir
|
54
|
+
source.save path
|
55
|
+
return false if !save
|
56
|
+
create_profiles
|
57
|
+
rescue StandardError => e
|
58
|
+
errors[:base] << e.message
|
59
|
+
return false
|
60
|
+
end
|
61
|
+
else
|
62
|
+
save
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def valid_store_attempt
|
67
|
+
new_record? and !@scap_file.nil?
|
68
|
+
end
|
69
|
+
|
70
|
+
def source
|
71
|
+
@source ||= source_init
|
72
|
+
end
|
73
|
+
|
74
|
+
def digest
|
75
|
+
self[:digest] ||= Digest::SHA256.hexdigest "#{@scap_file}"
|
76
|
+
end
|
77
|
+
|
78
|
+
def path
|
79
|
+
"#{dir}/#{digest}"
|
80
|
+
end
|
81
|
+
|
82
|
+
private
|
83
|
+
def source_init
|
84
|
+
OpenSCAP.oscap_init
|
85
|
+
if new_record?
|
86
|
+
OpenSCAP::Source.new(:content => @scap_file, :path => path)
|
87
|
+
else
|
88
|
+
OpenSCAP::Source.new path
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def dir
|
93
|
+
"#{Scaptimony::Engine.dir}/content"
|
94
|
+
end
|
95
|
+
|
96
|
+
def create_profiles
|
97
|
+
sds = ::OpenSCAP::DS::Sds.new source
|
98
|
+
bench_source = sds.select_checklist!
|
99
|
+
bench = ::OpenSCAP::Xccdf::Benchmark.new bench_source
|
100
|
+
bench.profiles.each { |key, profile|
|
101
|
+
scap_content_profiles.create!(:profile_id => key, :title => profile.title)
|
102
|
+
}
|
103
|
+
bench.destroy
|
104
|
+
sds.destroy
|
105
|
+
true
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Scaptimony
|
2
|
+
class XccdfRule < ActiveRecord::Base
|
3
|
+
# This is just an enumeration of ID's that have been found in the XCCDF contents uploaded
|
4
|
+
# to Scaptimony.
|
5
|
+
#
|
6
|
+
# Each Xccdf:Rule may have contain other data useful to users (Title, idents, and description,
|
7
|
+
# ...). These however needs to be carried by different entity (XccdfContentRule presumably).
|
8
|
+
# That is because different XCCDF contents may refer to the very same ID, even though it may
|
9
|
+
# have slightly different meaning in the context of given policy.
|
10
|
+
#
|
11
|
+
# There is still value in being able to enumerate the rules regardless of the policy. As we
|
12
|
+
# can expect that when the ID matches, most of the things will match as well (consider
|
13
|
+
# different version of the same policy). User may then want to search the results for a given
|
14
|
+
# rule.
|
15
|
+
#
|
16
|
+
validates :xid, :presence => true, :uniqueness => true
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Scaptimony
|
2
|
+
class XccdfRuleResult < ActiveRecord::Base
|
3
|
+
belongs_to :arf_report
|
4
|
+
belongs_to :xccdf_result
|
5
|
+
belongs_to :xccdf_rule
|
6
|
+
|
7
|
+
def self.f result_name
|
8
|
+
includes(:xccdf_result).where("scaptimony_xccdf_results.name = '#{result_name}'")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class CreateScaptimonyPolicyRevisions < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :scaptimony_policy_revisions do |t|
|
4
|
+
t.references :policy, index: true
|
5
|
+
t.references :scap_content, index: true
|
6
|
+
t.string :xccdf_profile
|
7
|
+
t.string :period
|
8
|
+
t.string :weekday
|
9
|
+
t.timestamp :active_until
|
10
|
+
|
11
|
+
t.timestamps
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class AddColumnsToScaptimonyPolicies < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
add_column :scaptimony_policies, :xccdf_profile, :string
|
4
|
+
add_column :scaptimony_policies, :period, :string
|
5
|
+
add_column :scaptimony_policies, :weekday, :string
|
6
|
+
add_column :scaptimony_policies, :description, :string
|
7
|
+
|
8
|
+
#This works only with rails-4, I want to support rails-3 too
|
9
|
+
# add_reference :scaptimony_policies, :scap_content, index: true
|
10
|
+
add_column :scaptimony_policies, :scap_content_id, :integer, references: :scap_content
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
class AddColumnsToScaptimonyScapContents < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
add_column :scaptimony_scap_contents, :title, :string
|
4
|
+
add_column :scaptimony_scap_contents, :original_filename, :string
|
5
|
+
add_index :scaptimony_scap_contents, :title
|
6
|
+
add_index :scaptimony_scap_contents, :original_filename
|
7
|
+
end
|
8
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateScaptimonyScapContentProfiles < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :scaptimony_scap_content_profiles do |t|
|
4
|
+
t.references :scap_content, index: true
|
5
|
+
t.string :profile_id
|
6
|
+
t.string :title
|
7
|
+
|
8
|
+
end
|
9
|
+
add_index :scaptimony_scap_content_profiles, [:scap_content_id, :profile_id],
|
10
|
+
:unique => true, :name => :index_scaptimony_scap_content_profiles_scipi
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
class CreateScaptimonyXccdfRuleResults < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :scaptimony_xccdf_rule_results do |t|
|
4
|
+
t.references :arf_report, index: true, null: false
|
5
|
+
t.references :xccdf_result, index: true, null: false
|
6
|
+
t.references :xccdf_rule, index: true, null: false
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class CreateScaptimonyArfReportBreakdowns < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
execute <<-SQL
|
4
|
+
CREATE VIEW scaptimony_arf_report_breakdowns AS
|
5
|
+
SELECT
|
6
|
+
arf.id as arf_report_id,
|
7
|
+
COUNT(CASE WHEN result.name IN ('pass','fixed') THEN 1 ELSE null END) as passed,
|
8
|
+
COUNT(CASE result.name WHEN 'fail' THEN 1 ELSE null END) as failed,
|
9
|
+
COUNT(CASE WHEN result.name NOT IN ('pass', 'fixed', 'fail', 'notselected', 'notapplicable') THEN 1 ELSE null END) as othered
|
10
|
+
FROM
|
11
|
+
scaptimony_arf_reports arf,
|
12
|
+
scaptimony_xccdf_rule_results rule,
|
13
|
+
scaptimony_xccdf_results result
|
14
|
+
WHERE
|
15
|
+
arf.id = rule.arf_report_id
|
16
|
+
AND rule.xccdf_result_id = result.id
|
17
|
+
GROUP BY arf.id;
|
18
|
+
SQL
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class ReplaceArfReportBreakdownView < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
execute <<-SQL
|
4
|
+
CREATE OR REPLACE VIEW scaptimony_arf_report_breakdowns AS
|
5
|
+
SELECT
|
6
|
+
arf.id as arf_report_id,
|
7
|
+
COUNT(CASE WHEN result.name IN ('pass','fixed') THEN 1 ELSE null END) as passed,
|
8
|
+
COUNT(CASE result.name WHEN 'fail' THEN 1 ELSE null END) as failed,
|
9
|
+
COUNT(CASE WHEN result.name NOT IN ('pass', 'fixed', 'fail', 'notselected', 'notapplicable') THEN 1 ELSE null END) as othered
|
10
|
+
FROM
|
11
|
+
scaptimony_arf_reports arf
|
12
|
+
LEFT OUTER JOIN
|
13
|
+
scaptimony_xccdf_rule_results rule
|
14
|
+
ON arf.id = rule.arf_report_id
|
15
|
+
LEFT OUTER JOIN scaptimony_xccdf_results result
|
16
|
+
ON rule.xccdf_result_id = result.id
|
17
|
+
GROUP BY arf.id;
|
18
|
+
SQL
|
19
|
+
end
|
20
|
+
end
|
data/db/seeds.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
Scaptimony::XccdfResult.create(:name => 'pass')
|
2
|
+
Scaptimony::XccdfResult.create(:name => 'fail')
|
3
|
+
Scaptimony::XccdfResult.create(:name => 'error')
|
4
|
+
Scaptimony::XccdfResult.create(:name => 'unknown')
|
5
|
+
Scaptimony::XccdfResult.create(:name => 'notapplicable')
|
6
|
+
Scaptimony::XccdfResult.create(:name => 'notchecked')
|
7
|
+
Scaptimony::XccdfResult.create(:name => 'notselected')
|
8
|
+
Scaptimony::XccdfResult.create(:name => 'informational')
|
9
|
+
Scaptimony::XccdfResult.create(:name => 'fixed')
|
@@ -14,7 +14,7 @@ module Scaptimony
|
|
14
14
|
module ArfReportsHelper
|
15
15
|
def self.create_arf(asset, params, arf_bzip)
|
16
16
|
# TODO:RAILS-4.0: This should become policy = Policy.find_or_create_by!(name: params[:policy])
|
17
|
-
policy = Policy.
|
17
|
+
policy = Policy.where(:name => params[:policy]).first_or_create!
|
18
18
|
digest = Digest::SHA256.hexdigest arf_bzip
|
19
19
|
# TODO:RAILS-4.0: This should become arf_report = ArfReport.find_or_create_by! ...
|
20
20
|
arf_report = ArfReport.where(:asset_id => asset.id, :policy_id => policy.id, :date => params[:date], :digest => digest).first_or_create!
|
data/lib/scaptimony/engine.rb
CHANGED
data/lib/scaptimony/version.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
2
|
+
|
3
|
+
one:
|
4
|
+
policy_id: 1
|
5
|
+
scap_content_id: 1
|
6
|
+
xccdf_profile: MyString
|
7
|
+
period: MyString
|
8
|
+
weekday: MyString
|
9
|
+
active_until: 2014-11-04 18:15:45
|
10
|
+
|
11
|
+
two:
|
12
|
+
policy_id: 1
|
13
|
+
scap_content_id: 1
|
14
|
+
xccdf_profile: MyString
|
15
|
+
period: MyString
|
16
|
+
weekday: MyString
|
17
|
+
active_until: 2014-11-04 18:15:45
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scaptimony
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Šimon Lukašík
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.2.8
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: openscap
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.4.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.4.0
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: sqlite3
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,14 +67,37 @@ files:
|
|
53
67
|
- app/controllers/scaptimony/application_controller.rb
|
54
68
|
- app/assets/stylesheets/scaptimony/application.css
|
55
69
|
- app/assets/javascripts/scaptimony/application.js
|
70
|
+
- app/models/scaptimony/xccdf_rule_result.rb
|
71
|
+
- app/models/scaptimony/scap_content.rb
|
56
72
|
- app/models/scaptimony/policy.rb
|
73
|
+
- app/models/scaptimony/policy_revision.rb
|
57
74
|
- app/models/scaptimony/arf_report.rb
|
75
|
+
- app/models/scaptimony/xccdf_rule.rb
|
76
|
+
- app/models/scaptimony/xccdf_result.rb
|
58
77
|
- app/models/scaptimony/asset.rb
|
78
|
+
- app/models/scaptimony/scap_content_profile.rb
|
79
|
+
- app/models/scaptimony/arf_report_breakdown.rb
|
59
80
|
- config/routes.rb
|
81
|
+
- db/migrate/20141116171305_add_profile_to_scaptimony_policies.rb
|
82
|
+
- db/migrate/20141116170632_remove_xccdf_profile_from_scaptimony_policies.rb
|
83
|
+
- db/migrate/20141119182606_create_scaptimony_xccdf_rule_results.rb
|
60
84
|
- db/migrate/20141015115511_add_arf_report_unique_constraint.rb
|
61
85
|
- db/migrate/20141015092642_create_scaptimony_arf_reports.rb
|
86
|
+
- db/migrate/20141119175434_create_scaptimony_xccdf_rules.rb
|
62
87
|
- db/migrate/20141014105333_create_scaptimony_assets.rb
|
88
|
+
- db/migrate/20141119164918_create_scaptimony_xccdf_results.rb
|
89
|
+
- db/migrate/20141107091756_add_columns_to_scaptimony_scap_contents.rb
|
90
|
+
- db/migrate/20141113221054_create_scaptimony_scap_content_profiles.rb
|
91
|
+
- db/migrate/20141111104519_add_constraint_to_scaptimony_scap_contents.rb
|
92
|
+
- db/migrate/20141105174834_add_columns_to_scaptimony_policies.rb
|
93
|
+
- db/migrate/20141104164201_create_scaptimony_scap_contents.rb
|
63
94
|
- db/migrate/20141013172051_create_scaptimony_policies.rb
|
95
|
+
- db/migrate/20141105174625_add_description_to_scaptimony_policy_revisions.rb
|
96
|
+
- db/migrate/20141104171545_create_scaptimony_policy_revisions.rb
|
97
|
+
- db/migrate/20141121120326_create_scaptimony_arf_report_breakdowns.rb
|
98
|
+
- db/migrate/20141118142954_add_constraint_to_scaptimony_policies.rb
|
99
|
+
- db/migrate/20141121164042_replace_arf_report_breakdown_view.rb
|
100
|
+
- db/seeds.rb
|
64
101
|
- lib/scaptimony.rb
|
65
102
|
- lib/tasks/scaptimony_tasks.rake
|
66
103
|
- lib/scaptimony/engine.rb
|
@@ -97,15 +134,28 @@ files:
|
|
97
134
|
- test/dummy/config/locales/en.yml
|
98
135
|
- test/dummy/config.ru
|
99
136
|
- test/dummy/README.rdoc
|
137
|
+
- test/fixtures/scaptimony/scap_contents.yml
|
138
|
+
- test/fixtures/scaptimony/xccdf_rule_results.yml
|
139
|
+
- test/fixtures/scaptimony/xccdf_results.yml
|
100
140
|
- test/fixtures/scaptimony/policies.yml
|
141
|
+
- test/fixtures/scaptimony/xccdf_rules.yml
|
142
|
+
- test/fixtures/scaptimony/policy_revisions.yml
|
101
143
|
- test/fixtures/scaptimony/arf_reports.yml
|
144
|
+
- test/fixtures/scaptimony/scap_content_profiles.yml
|
102
145
|
- test/fixtures/scaptimony/assets.yml
|
103
146
|
- test/scaptimony_test.rb
|
104
147
|
- test/lib/scaptimony/arf_reports_helper_test.rb
|
105
148
|
- test/test_helper.rb
|
106
149
|
- test/integration/navigation_test.rb
|
150
|
+
- test/models/scaptimony/scap_content_profiles_test.rb
|
151
|
+
- test/models/scaptimony/policy_revision_test.rb
|
152
|
+
- test/models/scaptimony/xccdf_rule_test.rb
|
153
|
+
- test/models/scaptimony/scap_content_test.rb
|
154
|
+
- test/models/scaptimony/xccdf_result_test.rb
|
155
|
+
- test/models/scaptimony/arf_report_breakdown_test.rb
|
107
156
|
- test/models/scaptimony/arf_report_test.rb
|
108
157
|
- test/models/scaptimony/asset_test.rb
|
158
|
+
- test/models/scaptimony/xccdf_rule_result_test.rb
|
109
159
|
- test/models/scaptimony/policy_test.rb
|
110
160
|
homepage: https://github.com/OpenSCAP/scaptimony
|
111
161
|
licenses:
|
@@ -160,13 +210,26 @@ test_files:
|
|
160
210
|
- test/dummy/config/locales/en.yml
|
161
211
|
- test/dummy/config.ru
|
162
212
|
- test/dummy/README.rdoc
|
213
|
+
- test/fixtures/scaptimony/scap_contents.yml
|
214
|
+
- test/fixtures/scaptimony/xccdf_rule_results.yml
|
215
|
+
- test/fixtures/scaptimony/xccdf_results.yml
|
163
216
|
- test/fixtures/scaptimony/policies.yml
|
217
|
+
- test/fixtures/scaptimony/xccdf_rules.yml
|
218
|
+
- test/fixtures/scaptimony/policy_revisions.yml
|
164
219
|
- test/fixtures/scaptimony/arf_reports.yml
|
220
|
+
- test/fixtures/scaptimony/scap_content_profiles.yml
|
165
221
|
- test/fixtures/scaptimony/assets.yml
|
166
222
|
- test/scaptimony_test.rb
|
167
223
|
- test/lib/scaptimony/arf_reports_helper_test.rb
|
168
224
|
- test/test_helper.rb
|
169
225
|
- test/integration/navigation_test.rb
|
226
|
+
- test/models/scaptimony/scap_content_profiles_test.rb
|
227
|
+
- test/models/scaptimony/policy_revision_test.rb
|
228
|
+
- test/models/scaptimony/xccdf_rule_test.rb
|
229
|
+
- test/models/scaptimony/scap_content_test.rb
|
230
|
+
- test/models/scaptimony/xccdf_result_test.rb
|
231
|
+
- test/models/scaptimony/arf_report_breakdown_test.rb
|
170
232
|
- test/models/scaptimony/arf_report_test.rb
|
171
233
|
- test/models/scaptimony/asset_test.rb
|
234
|
+
- test/models/scaptimony/xccdf_rule_result_test.rb
|
172
235
|
- test/models/scaptimony/policy_test.rb
|