inspecstyle 0.1.3 → 0.1.4
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 +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +34 -0
- data/config/default.yml +10 -0
- data/lib/rubocop/cop/inspecstyle/deprecated_attributes.rb +0 -1
- data/lib/rubocop/cop/inspecstyle/first_cop.rb +0 -1
- data/lib/rubocop/cop/inspecstyle/oracle_db_session_pass.rb +37 -0
- data/lib/rubocop/cop/inspecstyle/shadow_properties.rb +52 -0
- data/lib/rubocop/cop/inspecstyle_cops.rb +2 -0
- data/lib/rubocop/inspecstyle/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bb0e545b5334db0eea3a814b9a3c1c190faf6ed830283ae30e20d2ffca09d18
|
4
|
+
data.tar.gz: '0926fd1659d8c3902c687f5b8316dc6871320e8ea4c123ba74fd170798d45728'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0585d52d51d05c5962359ffc981547dc5b87e9561eec671c248833ee537ea29f207a9347d08bd8bf5802a585b1c6b275a365b43b0c8267afec1d7a6a960ce163'
|
7
|
+
data.tar.gz: 93a55953bd3e49b2072eb9a85fd82230c2dbb8ce78b7b6cb84cd6a7c12cadaadc4cb87c85ba90874f9d8d0e1e6b8bb24939c494784e734b6a3edfa7e60b98995
|
data/Gemfile.lock
CHANGED
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
|
|
data/config/default.yml
CHANGED
@@ -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
|
@@ -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
|
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.
|
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
|