scelint 0.4.1 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4a057d6c2d1fea9e9d5ff8cc067236685a6c5fa1458091535c8b64e7e7faddf1
4
- data.tar.gz: c520052501d0af91fd1b031cdf41e6c8e1185b4475d4b51385d2c45cc326a12f
3
+ metadata.gz: fc7289501df2ba7489119cef80aff1319b3d4e3ced3c7256f77db2fadb757447
4
+ data.tar.gz: 03347cf49d0b25dfe69b1b20efc9288063b3003bd9b83c73f7096468a3d19a28
5
5
  SHA512:
6
- metadata.gz: e9ff311ea144f952f84f3215bfec4833370216e4fb89b10fcf03a1577b391e55ea66d75f6ca887c86214ad09a7b0a9f91c3237c9e1645af13f1a359cd069ed10
7
- data.tar.gz: 575be45fdf396183fe5dee7e19d6b990b21f8a17e55f7f8620a7441945a82796ce159fe2986f7d5a01a62f3865e8a191383b7c7f7a49a664d7ef00e363af9d92
6
+ metadata.gz: c453ffc5c435214e2a18b36f15f79362301500185311e76c674b4b9c7c040c29ff6816df81898a5b23f0a0c94d4f8abc42dd987749310ad6a3f38def9d67c3cc
7
+ data.tar.gz: 739acfe53764dff91810874f45a87ed697ee91915aeb5ee440e6d6350da602ab5ca64b9737c755b7cfee98ede884b80c015c8df4b10a465b928a790ebad04b8e
@@ -17,7 +17,7 @@ jobs:
17
17
  - name: "Install Ruby"
18
18
  uses: ruby/setup-ruby@v1
19
19
  with:
20
- ruby-version: 4.0.0
20
+ ruby-version: 4.0.1
21
21
  bundler-cache: true
22
22
  - run: bundle exec rake rubocop
23
23
 
@@ -92,7 +92,7 @@ jobs:
92
92
  echo "release_command=$GEM_RELEASE_COMMAND" | tee -a "$GITHUB_OUTPUT"
93
93
  - uses: ruby/setup-ruby@v1
94
94
  with:
95
- ruby-version: 4.0.0
95
+ ruby-version: 4.0.1
96
96
  bundler-cache: true
97
97
  - name: Test build the package
98
98
  run: "${{ steps.commands.outputs.build_command }}"
@@ -187,7 +187,7 @@ jobs:
187
187
  clean: true
188
188
  - uses: ruby/setup-ruby@v1
189
189
  with:
190
- ruby-version: 4.0.0
190
+ ruby-version: 4.0.1
191
191
  bundler-cache: true
192
192
  - name: Build RubyGem
193
193
  run: |
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 0.5.0 / 2026-03-11
2
+ * Validate parameter names
3
+ * Fix command-line argument processing
4
+
1
5
  ### 0.4.1 / 2026-01-26
2
6
  * Support compliance_engine 0.2.x
3
7
  * Test with Ruby 4.0
data/Gemfile CHANGED
@@ -7,7 +7,7 @@ gem 'rake', '~> 13.3.0'
7
7
 
8
8
  group :tests do
9
9
  gem 'rspec', '~> 3.13.1'
10
- gem 'rubocop', '~> 1.81.0'
10
+ gem 'rubocop', '~> 1.85.0'
11
11
  gem 'rubocop-performance', '~> 1.26.0'
12
12
  gem 'rubocop-rake', '~> 0.7.1'
13
13
  gem 'rubocop-rspec', '~> 3.9.0'
@@ -16,5 +16,5 @@ end
16
16
  group :development do
17
17
  gem 'pry', '~> 0.16.0'
18
18
  gem 'pry-byebug', '~> 3.12.0'
19
- gem 'rdoc', '~> 7.1.0'
19
+ gem 'rdoc', '~> 7.2.0'
20
20
  end
data/exe/scelint CHANGED
@@ -3,4 +3,4 @@
3
3
 
4
4
  require 'scelint/cli'
5
5
 
6
- Scelint::CLI.start(['lint'] + ARGV)
6
+ Scelint::CLI.start
data/lib/scelint/cli.rb CHANGED
@@ -6,6 +6,20 @@ require 'logger'
6
6
 
7
7
  # SCELint CLI
8
8
  class Scelint::CLI < Thor
9
+ def self.exit_on_failure?
10
+ true
11
+ end
12
+
13
+ # When the first argument is not a known subcommand or an option flag,
14
+ # treat all arguments as paths for the default `lint` command.
15
+ def self.start(given_args = ARGV, config = {})
16
+ args = given_args
17
+ if args.first && !args.first.start_with?('-') && !all_commands.key?(args.first)
18
+ args = ['lint'] + args
19
+ end
20
+ super(args, config)
21
+ end
22
+
9
23
  class_option :quiet, type: :boolean, aliases: '-q', default: false
10
24
  class_option :verbose, type: :boolean, aliases: '-v', default: false
11
25
  class_option :debug, type: :boolean, aliases: '-d', default: false
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Scelint
4
- VERSION = '0.4.1'
4
+ VERSION = '0.5.0'
5
5
  end
data/lib/scelint.rb CHANGED
@@ -396,7 +396,33 @@ module Scelint
396
396
  # @param check [String] The name of the check
397
397
  # @param parameter [String] The parameter to validate
398
398
  def check_parameter(file, check, parameter)
399
- errors << "#{file} (check '#{check}'): invalid parameter '#{parameter}'" unless parameter.is_a?(String) && !parameter.empty?
399
+ # Regular expression to match valid Puppet class parameter names
400
+ valid_parameter = %r{\A([a-z][a-z0-9_]*::)+[a-z][a-z0-9_]*\z}
401
+ # From https://www.puppet.com/docs/puppet/7/lang_reserved.html
402
+ reserved_words = ['and', 'application', 'attr', 'case', 'component', 'consumes', 'default', 'define', 'elsif',
403
+ 'environment', 'false', 'function', 'if', 'import', 'in', 'inherits', 'node',
404
+ 'or', 'private', 'produces', 'regexp', 'site', 'true', 'type', 'undef', 'unit', 'unless',
405
+ 'main', 'settings', 'init', 'any', 'array', 'binary', 'boolean', 'catalogentry', 'class',
406
+ 'collection', 'callable', 'data', 'default', 'deferred', 'enum', 'float', 'hash', 'integer',
407
+ 'notundef', 'numeric', 'optional', 'pattern', 'resource', 'regexp', 'runtime', 'scalar',
408
+ 'semver', 'semVerRange', 'sensitive', 'string', 'struct', 'timespan', 'timestamp', 'tuple',
409
+ 'type', 'undef', 'variant', 'facts', 'trusted', 'server_facts', 'title', 'name'].freeze
410
+
411
+ unless parameter.is_a?(String) && !parameter.empty?
412
+ errors << "#{file} (check '#{check}'): invalid parameter '#{parameter}'"
413
+ return
414
+ end
415
+
416
+ unless parameter.match?(valid_parameter)
417
+ errors << "#{file} (check '#{check}'): invalid parameter name '#{parameter}'"
418
+ return
419
+ end
420
+
421
+ parameter.split('::').each do |part|
422
+ if reserved_words.include?(part)
423
+ errors << "#{file} (check '#{check}'): parameter name '#{parameter}' contains reserved word '#{part}'"
424
+ end
425
+ end
400
426
  end
401
427
 
402
428
  # Check remediation
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scelint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Pritchard