scelint 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.github/workflows/add_new_issue_to_triage_project.yml +40 -0
- data/.github/workflows/pr_tests.yml +42 -0
- data/.github/workflows/tag_deploy_rubygem.yml +212 -0
- data/.gitignore +16 -0
- data/.rspec +3 -0
- data/.rubocop.yml +748 -0
- data/CHANGELOG.md +23 -0
- data/Gemfile +20 -0
- data/README.md +13 -0
- data/Rakefile +12 -0
- data/exe/scelint +6 -0
- data/lib/scelint/cli.rb +80 -0
- data/lib/scelint/version.rb +5 -0
- data/lib/scelint.rb +716 -0
- data/scelint.gemspec +30 -0
- metadata +103 -0
data/CHANGELOG.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
### 0.3.0 / 2025-01-16
|
2
|
+
* Use compliance_engine gem for data ingest
|
3
|
+
* Check that all fact combinations return hiera data
|
4
|
+
* Add `notes` for info-level log items
|
5
|
+
* Re-add merged data checks
|
6
|
+
* Clean up for release
|
7
|
+
|
8
|
+
### 0.2.0 / 2024-10-29
|
9
|
+
* Add --strict option to make warnings fatal
|
10
|
+
* Warn on legacy facts in confine
|
11
|
+
* Make check_confine more strict
|
12
|
+
- Warn if any confine key is another check key (to catch bad indentation in YAML source)
|
13
|
+
* Refactor CLI to use thor
|
14
|
+
* Add quiet/verbose/debug options to the CLI
|
15
|
+
* Bump minimum required Ruby version to 2.7.0 (oldest version we're testing with)
|
16
|
+
* Accept 'id' and 'benchmark_version' in profiles
|
17
|
+
* Fix accidental merge of nested data
|
18
|
+
* Make missing keys an error only on merged data
|
19
|
+
* Clarify error messages in `check_settings`
|
20
|
+
* Update gem email and homepage for move to SIMP org
|
21
|
+
|
22
|
+
### 0.1.0 / 2020-11-12
|
23
|
+
* Initial unreleased version
|
data/Gemfile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in scelint.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
gem 'rake', '~> 13.2'
|
7
|
+
|
8
|
+
group :tests do
|
9
|
+
gem 'rspec', '~> 3.13'
|
10
|
+
gem 'rubocop', '~> 1.65'
|
11
|
+
gem 'rubocop-performance', '~> 1.21'
|
12
|
+
gem 'rubocop-rake', '~> 0.6.0'
|
13
|
+
gem 'rubocop-rspec', '~> 3.0'
|
14
|
+
end
|
15
|
+
|
16
|
+
group :development do
|
17
|
+
gem 'pry', '~> 0.14.1'
|
18
|
+
gem 'pry-byebug', '~> 3.10'
|
19
|
+
gem 'rdoc', '~> 6.4'
|
20
|
+
end
|
data/README.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# `scelint`
|
2
|
+
|
3
|
+
Lint SIMP Compliance Engine data.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
With no arguments, the included `scelint` script will look for SCE data in the standard load path (`SIMP/compliance_profiles`) under the current directory.
|
8
|
+
Alternatively, any file arguments specified will be loaded directly. Any directory arguments will be searched under the standard load path.
|
9
|
+
|
10
|
+
## Contributing
|
11
|
+
|
12
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/silug/rubygem-simp-scelint.
|
13
|
+
|
data/Rakefile
ADDED
data/exe/scelint
ADDED
data/lib/scelint/cli.rb
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'scelint'
|
4
|
+
require 'thor'
|
5
|
+
require 'logger'
|
6
|
+
|
7
|
+
# SCELint CLI
|
8
|
+
class Scelint::CLI < Thor
|
9
|
+
class_option :quiet, type: :boolean, aliases: '-q', default: false
|
10
|
+
class_option :verbose, type: :boolean, aliases: '-v', default: false
|
11
|
+
class_option :debug, type: :boolean, aliases: '-d', default: false
|
12
|
+
|
13
|
+
desc 'lint PATH', 'Lint all files in PATH'
|
14
|
+
option :strict, type: :boolean, aliases: '-s', default: false
|
15
|
+
def lint(*paths)
|
16
|
+
paths = ['.'] if paths.nil? || paths.empty?
|
17
|
+
lint = Scelint::Lint.new(paths, logger: logger)
|
18
|
+
|
19
|
+
count = lint.files.count
|
20
|
+
|
21
|
+
if count.zero?
|
22
|
+
logger.error 'No SCE data found.'
|
23
|
+
exit 0
|
24
|
+
end
|
25
|
+
|
26
|
+
lint.errors.each do |error|
|
27
|
+
logger.error error
|
28
|
+
end
|
29
|
+
|
30
|
+
lint.warnings.each do |warning|
|
31
|
+
logger.warn warning
|
32
|
+
end
|
33
|
+
|
34
|
+
lint.notes.each do |note|
|
35
|
+
logger.info note
|
36
|
+
end
|
37
|
+
|
38
|
+
message = "Checked #{count} files."
|
39
|
+
if lint.errors.count == 0
|
40
|
+
message += ' No errors.'
|
41
|
+
exit_code = 0
|
42
|
+
else
|
43
|
+
message += " #{lint.errors.count} errors."
|
44
|
+
exit_code = 1
|
45
|
+
end
|
46
|
+
|
47
|
+
if lint.warnings.count > 0
|
48
|
+
message += " #{lint.warnings.count} warnings."
|
49
|
+
exit_code = 1 if options[:strict]
|
50
|
+
end
|
51
|
+
|
52
|
+
message += " #{lint.notes.count} notes." if lint.notes.count > 0
|
53
|
+
|
54
|
+
logger.info message
|
55
|
+
exit exit_code
|
56
|
+
rescue => e
|
57
|
+
logger.fatal e.message
|
58
|
+
end
|
59
|
+
default_task :lint
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def logger
|
64
|
+
return @logger if @logger
|
65
|
+
@logger = Logger.new(STDOUT)
|
66
|
+
if options[:quiet]
|
67
|
+
@logger.level = Logger::FATAL
|
68
|
+
elsif options[:debug]
|
69
|
+
@logger.level = Logger::DEBUG
|
70
|
+
elsif options[:verbose]
|
71
|
+
@logger.level = Logger::INFO
|
72
|
+
else
|
73
|
+
@logger.level = Logger::INFO
|
74
|
+
@logger.formatter = proc do |_severity, _datetime, _progname, msg|
|
75
|
+
"#{msg}\n"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
@logger
|
79
|
+
end
|
80
|
+
end
|