siteguard_lite-custom_signature 0.4.0 → 0.5.0

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: 2afd93f858fa218143f84c0f9f17d1193240151c01143e957eb486441072b415
4
- data.tar.gz: 29790f84d51e9781f1d50c1dda38b37475b7a0d568e5690b04ecd73f4b5261cd
3
+ metadata.gz: 123971b24064f124e88b1636b2ec2be1f0a9209ff86e9caa1f7e3e1800bbcfa7
4
+ data.tar.gz: dceefee584c5b09f79eb90b918d2094d3ac1682d2c68e6503c3c2973c8cdbde1
5
5
  SHA512:
6
- metadata.gz: 29d812d5abbc1935b228a3bc1035359302ff1a07314e52d2fc5dd750fac7a6fe6331426b32feccae819eead5383bd146ef803eef0eca8d56d2f107cbf0d8c332
7
- data.tar.gz: b9d2fccf098915d39214cbed4293f58503d7b328c58b1a55ec01152cda27f682a1004854bd29214dad911c3f5012485712cf4e31d6bea9a754f1f6d7a0c88bf4
6
+ metadata.gz: 146c2bae738d1a9c1b6f65a3a921c7e47f1a99439dd460a1eddd14dcf3e5b51ac2e74b80b3ded8df0c22ea7c660552cba17b083d8e374e0df839257a9ac11eab
7
+ data.tar.gz: 9722d622d5ba590d9eb6e58764be52e18fd0a3e4213df4b0769ded720a3c653a5c784213cacded71dbc463483948d7f92674d18b56ddbb87ac4dc667010e1a9d
@@ -0,0 +1,26 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+
13
+ strategy:
14
+ matrix:
15
+ ruby: ['2.6', '2.7']
16
+
17
+ steps:
18
+ - uses: actions/checkout@v2
19
+
20
+ - uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version: ${{ matrix.ruby }}
23
+
24
+ - run: bin/setup
25
+
26
+ - run: bundle exec rake spec
@@ -17,10 +17,9 @@ module SiteguardLite
17
17
  # [有効・無効]<タブ>[動作]<タブ><タブ>[シグネチャ名]<タブ>[検査対象] <タブ>[比較方法]<タブ> [検査文字列]<タブ><タブ>[コメント]
18
18
  def to_text(rule, last: false)
19
19
  validate!
20
-
21
20
  [
22
21
  rule.enable_str,
23
- rule.action,
22
+ rule.action_str,
24
23
  '',
25
24
  rule.name,
26
25
  @key,
@@ -3,12 +3,13 @@ module SiteguardLite
3
3
  class Rule
4
4
  include ActiveModel::Validations
5
5
 
6
- attr_reader :name, :action, :comment, :enable, :conditions
7
- attr_accessor :exclusion_action, :signature
6
+ attr_reader :name, :comment, :enable, :conditions, :filter_lifetime
7
+ attr_accessor :action, :exclusion_action, :signature
8
8
 
9
9
  validates :name, bytesize: { maximum: 29 }
10
10
  validates :signature, bytesize: { maximum: 999 }
11
- validates :action, inclusion: %w(BLOCK NONE WHITE) # TODO support FILTER action
11
+ validates :filter_lifetime, format: { with: /\A\d+\z/ }, allow_nil: true
12
+ validates :action, inclusion: %w(BLOCK NONE WHITE FILTER)
12
13
 
13
14
  def initialize(args)
14
15
  @name = args[:name]
@@ -17,6 +18,12 @@ module SiteguardLite
17
18
  @signature = args[:signature]
18
19
  @action = args[:action] || 'NONE'
19
20
 
21
+ if @action == 'FILTER'
22
+ @filter_lifetime = args[:filter_lifetime] || '300'
23
+ else
24
+ @filter_lifetime = nil
25
+ end
26
+
20
27
  @enable = true
21
28
 
22
29
  @conditions = []
@@ -30,6 +37,10 @@ module SiteguardLite
30
37
  @enable ? 'ON' : 'OFF'
31
38
  end
32
39
 
40
+ def action_str
41
+ @action == 'FILTER' ? "#{@action}:#{@filter_lifetime}" : @action
42
+ end
43
+
33
44
  def to_text
34
45
  validate!
35
46
 
@@ -45,6 +56,7 @@ module SiteguardLite
45
56
  {
46
57
  name: @name,
47
58
  action: @action,
59
+ filter_lifetime: @filter_lifetime,
48
60
  comment: @comment,
49
61
  exclusion_action: @exclusion_action,
50
62
  signature: @signature,
@@ -1,13 +1,16 @@
1
1
  module SiteguardLite
2
2
  module CustomSignature
3
3
  class TextLineParser
4
+ FILTER_ACTION_REGEX = /\AFILTER:(\d+)\z/
5
+
4
6
  # siteguardlite-320-0_nginx.pdf, p.52
5
7
  # [有効・無効]<タブ>[動作]<タブ><タブ>[シグネチャ名]<タブ>[検査対象] <タブ>[比較方法]<タブ> [検査文字列]<タブ><タブ>[コメント]
6
8
  def parse(line)
7
9
  fields = line.split("\t")
8
10
  {
9
11
  enable: enable(fields[0]),
10
- action: fields[1],
12
+ action: parse_action(fields[1]),
13
+ filter_lifetime: parse_filter_lifetime(fields[1]),
11
14
  name: fields[3],
12
15
  comment: fields[8],
13
16
  exclusion_action: exclusion_action(fields[5]),
@@ -60,6 +63,19 @@ module SiteguardLite
60
63
 
61
64
  @parsed_comarison_str = result
62
65
  end
66
+
67
+ def parse_action(parsed_action)
68
+ case parsed_action
69
+ when FILTER_ACTION_REGEX
70
+ 'FILTER'
71
+ else
72
+ parsed_action
73
+ end
74
+ end
75
+
76
+ def parse_filter_lifetime(parsed_action)
77
+ parsed_action =~ FILTER_ACTION_REGEX ? $1 : nil
78
+ end
63
79
  end
64
80
  end
65
81
  end
@@ -23,6 +23,7 @@ module SiteguardLite
23
23
  rule = Rule.new(
24
24
  enable: parsed[:enable],
25
25
  action: parsed[:action],
26
+ filter_lifetime: parsed[:filter_lifetime],
26
27
  name: parsed[:name],
27
28
  comment: parsed[:comment],
28
29
  exclusion_action: parsed[:exclusion_action],
@@ -1,5 +1,5 @@
1
1
  module SiteguardLite
2
2
  module CustomSignature
3
- VERSION = "0.4.0"
3
+ VERSION = "0.5.0"
4
4
  end
5
5
  end
@@ -8,6 +8,7 @@ module SiteguardLite
8
8
  rule = SiteguardLite::CustomSignature::Rule.new(
9
9
  name: r['name'],
10
10
  action: r['action'],
11
+ filter_lifetime: r['filter_lifetime'],
11
12
  comment: r['comment'],
12
13
  exclusion_action: r['exclusion_action'],
13
14
  signature: r['signature']
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": [
3
+ "config:base"
4
+ ]
5
+ }
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.add_dependency "activemodel"
25
25
  spec.add_dependency "activesupport"
26
26
 
27
- spec.add_development_dependency "bundler", "~> 1.16"
28
- spec.add_development_dependency "rake", "~> 10.0"
29
- spec.add_development_dependency "rspec", "~> 3.0"
27
+ spec.add_development_dependency "bundler"
28
+ spec.add_development_dependency "rake"
29
+ spec.add_development_dependency "rspec"
30
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: siteguard_lite-custom_signature
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takatoshi Ono
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-13 00:00:00.000000000 Z
11
+ date: 2020-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -42,44 +42,44 @@ dependencies:
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '1.16'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '1.16'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '10.0'
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '10.0'
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '3.0'
75
+ version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: '3.0'
82
+ version: '0'
83
83
  description: This library load and dump SiteGuard Lite custom signature file.
84
84
  email:
85
85
  - takatoshi.ono@gmail.com
@@ -87,9 +87,9 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
+ - ".github/workflows/ruby.yml"
90
91
  - ".gitignore"
91
92
  - ".rspec"
92
- - ".travis.yml"
93
93
  - Gemfile
94
94
  - LICENSE.txt
95
95
  - README.md
@@ -106,6 +106,7 @@ files:
106
106
  - lib/siteguard_lite/custom_signature/version.rb
107
107
  - lib/siteguard_lite/custom_signature/yaml_dumper.rb
108
108
  - lib/siteguard_lite/custom_signature/yaml_loader.rb
109
+ - renovate.json
109
110
  - siteguard_lite-custom_signature.gemspec
110
111
  homepage: https://github.com/pepabo/siteguard_lite-custom_signature
111
112
  licenses:
@@ -126,8 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
127
  - !ruby/object:Gem::Version
127
128
  version: '0'
128
129
  requirements: []
129
- rubyforge_project:
130
- rubygems_version: 2.7.6
130
+ rubygems_version: 3.0.3
131
131
  signing_key:
132
132
  specification_version: 4
133
133
  summary: This library load and dump SiteGuard Lite custom signature file.
@@ -1,5 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.5.1
5
- before_install: gem install bundler -v 1.16.1