inspecstyle 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a3f8cb06cac386264652e1005a6b23e975308fbd1887b469f20f528bdbb88563
4
- data.tar.gz: 24503e8b29b8f1876682f39c07e0e53080b03be08a295c885e8c49485f8137ba
3
+ metadata.gz: 0bb0e545b5334db0eea3a814b9a3c1c190faf6ed830283ae30e20d2ffca09d18
4
+ data.tar.gz: '0926fd1659d8c3902c687f5b8316dc6871320e8ea4c123ba74fd170798d45728'
5
5
  SHA512:
6
- metadata.gz: 40a105f93aa52b6ce4b36d972bf24750150e2c0ee3399483f4ec1675f94573c4df821a61ee6fa10a4fcd161fa4a87d0efdb73084aafe424f32813cc56dd67ba3
7
- data.tar.gz: 59288f41742905617e98f76f53290110636bc05c9b7c328bad78c12f07f5b059a28769ab9a30f56986e92cca9b5d6248cb3cd790ddcc7655f86f72a53fe79f47
6
+ metadata.gz: '0585d52d51d05c5962359ffc981547dc5b87e9561eec671c248833ee537ea29f207a9347d08bd8bf5802a585b1c6b275a365b43b0c8267afec1d7a6a960ce163'
7
+ data.tar.gz: 93a55953bd3e49b2072eb9a85fd82230c2dbb8ce78b7b6cb84cd6a7c12cadaadc4cb87c85ba90874f9d8d0e1e6b8bb24939c494784e734b6a3edfa7e60b98995
@@ -1,13 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- inspecstyle (0.1.2)
4
+ inspecstyle (0.1.3)
5
5
  rubocop
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- ast (2.4.0)
10
+ ast (2.4.1)
11
11
  diff-lcs (1.3)
12
12
  minitest (5.14.1)
13
13
  parallel (1.19.1)
data/README.md CHANGED
@@ -40,6 +40,40 @@ To only run these cops on your local rubocop run, execute:
40
40
  ## TODO:
41
41
 
42
42
  - Instead of referencing issues in the cops, point to a general `inspecstyle.guide`
43
+ - Known issue, resources that work on manual runs but not in `atom` package: [
44
+ - AzureGenericResource
45
+ ]
46
+ - Cop ideas:
47
+ ```
48
+ its('minimum_days_between_password_change') { should eq 0 } becomes 'mindays'
49
+ its('maximum_days_between_password_change') { should eq 0 } becomes 'maxdays'
50
+ Inspec.deprecate(:resource_user_serverspec_compat, "The user resource `has_home_directory?` matcher is deprecated. Please use `its('home')`.")
51
+ Inspec.deprecate(:resource_user_serverspec_compat, "The user resource `has_authorized_key?` matcher is deprecated. There is no currently implemented alternative")
52
+
53
+
54
+ shadow resource deprecations
55
+ (e.g.)
56
+ describe shadow('/etc/my-custom-place/shadow') do
57
+ its('count') { should eq 32 }
58
+ end
59
+
60
+ property deprecations:
61
+
62
+ user -> users
63
+ password -> passwords
64
+ last_change -> last_changes
65
+ expiry_date -> expiry_dates
66
+ lines (no replacement)
67
+
68
+ e.g.
69
+
70
+ sql = oracledb_session(user: 'my_user', pass: 'password')
71
+ describe sql.query(\"SELECT UPPER(VALUE) AS VALUE FROM V$PARAMETER WHERE UPPER(NAME)='AUDIT_SYS_OPERATIONS'\").row(0).column('value') do
72
+ its('value') { should eq 'TRUE' }
73
+ end
74
+
75
+ oracledb_session deprecated `pass`, use `password` instead
76
+ ```
43
77
 
44
78
  ## Development
45
79
 
@@ -11,6 +11,16 @@ InSpecStyle/DeprecatedAttributes:
11
11
  StyleGuide: 'https://github.com/inspec/inspec/issues/3802'
12
12
  PreferredReplacement: 'input'
13
13
 
14
+ InSpecStyle/OracleDbSessionPass:
15
+ Description: 'Use `pass` instead of `password`'
16
+ Enabled: true
17
+ VersionAdded: '0.82'
18
+
19
+ InSpecStyle/ShadowProperties:
20
+ Description: '`user` attribute for shadow resources is deprecated for `users`'
21
+ Enabled: true
22
+ VersionAdded: '0.82'
23
+
14
24
  InspecStyle/FirstCop:
15
25
  Description: 'This first cop is a sandbox for exploring new InspecStyle cops.'
16
26
  Enabled: true
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # TODO: when finished, run `rake generate_cops_documentation` to update the docs
4
3
  module RuboCop
5
4
  module Cop
6
5
  module InSpecStyle
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # TODO: when finished, run `rake generate_cops_documentation` to update the docs
4
3
  module RuboCop
5
4
  module Cop
6
5
  module InSpecStyle
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module InSpecStyle
6
+ #
7
+ # @example EnforcedStyle: InSpecStyle (default)
8
+ # # Description of the `bar` style.
9
+ #
10
+ # # bad
11
+ # sql = oracledb_session(user: 'my_user', pass: 'password')
12
+ #
13
+ # # good
14
+ # sql = oracledb_session(user: 'my_user', password: 'password')
15
+ class OracleDbSessionPass < Cop
16
+ include MatchRange
17
+ MSG = 'Use `:password` instead of `:pass`.'
18
+
19
+ def_node_matcher :oracledb_session_pass?, <<~PATTERN
20
+ (send _ :oracledb_session
21
+ (hash
22
+ ...
23
+ (pair
24
+ (sym $:pass)
25
+ ...)))
26
+ PATTERN
27
+
28
+ # Getting location was a bit tricky on this one, looking at docs perhaps
29
+ # convention does allow highlighting an entire line.
30
+ def on_send(node)
31
+ return unless result = oracledb_session_pass?(node)
32
+ add_offense(node, message: MSG)
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ # NOTE TO SELF - this one isn't currently working even though my pattern works in Rubocop's bin/console
4
+
5
+ module RuboCop
6
+ module Cop
7
+ module InSpecStyle
8
+ # Shadow resource property user is deprecated in favor of `users`
9
+ #
10
+ # @example EnforcedStyle: InSpecStyle (default)
11
+ # # Use users instead
12
+ #
13
+ # # bad
14
+ # describe shadow('/etc/my-custom-place/shadow') do
15
+ # its('user') { should eq 'user' }
16
+ # end
17
+ #
18
+ # # good
19
+ # describe shadow('/etc/my-custom-place/shadow') do
20
+ # its('users') { should eq 'user' }
21
+ # end
22
+ #
23
+ class ShadowProperties < Cop
24
+ # TODO: Implement the cop in here.
25
+ #
26
+ # In many cases, you can use a node matcher for matching node pattern.
27
+ # See https://github.com/rubocop-hq/rubocop-ast/blob/master/lib/rubocop/node_pattern.rb
28
+ #
29
+ # For example
30
+ MSG = 'Use `#users` instead of `#user`. This property will be removed '\
31
+ 'in InSpec 5'
32
+
33
+ def_node_matcher :shadow_resource_user_property?, <<~PATTERN
34
+ (block
35
+ (send _ :describe
36
+ (send _ :shadow ...) ...)
37
+ (args ...)
38
+ (block
39
+ (send _ :its
40
+ (str ${"user" "password" "last_change" "expiry_date" "line"} ...) ...) ...) ...)
41
+ PATTERN
42
+
43
+ def on_send(node)
44
+ return unless shadow_resource_user_property?(node)
45
+ require 'pry'
46
+ binding.pry
47
+ add_offense(node)
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -2,3 +2,5 @@
2
2
  require_relative 'inspecstyle/first_cop'
3
3
  require_relative 'inspecstyle/deprecated_attributes'
4
4
  require_relative 'inspecstyle/azure_generic_resource'
5
+ require_relative 'inspecstyle/shadow_properties'
6
+ require_relative 'inspecstyle/oracle_db_session_pass'
@@ -1,5 +1,5 @@
1
1
  module RuboCop
2
2
  module InSpecStyle
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inspecstyle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Schwaderer
@@ -74,6 +74,8 @@ files:
74
74
  - lib/rubocop/cop/inspecstyle/azure_generic_resource.rb
75
75
  - lib/rubocop/cop/inspecstyle/deprecated_attributes.rb
76
76
  - lib/rubocop/cop/inspecstyle/first_cop.rb
77
+ - lib/rubocop/cop/inspecstyle/oracle_db_session_pass.rb
78
+ - lib/rubocop/cop/inspecstyle/shadow_properties.rb
77
79
  - lib/rubocop/cop/inspecstyle_cops.rb
78
80
  - lib/rubocop/inspecstyle.rb
79
81
  - lib/rubocop/inspecstyle/inject.rb