sqreen-alt 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +7 -0
  2. data/CODE_OF_CONDUCT.md +22 -0
  3. data/README.md +77 -0
  4. data/Rakefile +20 -0
  5. data/lib/sqreen-alt.rb +1 -0
  6. data/lib/sqreen.rb +68 -0
  7. data/lib/sqreen/attack_detected.html +2 -0
  8. data/lib/sqreen/binding_accessor.rb +288 -0
  9. data/lib/sqreen/ca.crt +72 -0
  10. data/lib/sqreen/call_countable.rb +67 -0
  11. data/lib/sqreen/callback_tree.rb +78 -0
  12. data/lib/sqreen/callbacks.rb +100 -0
  13. data/lib/sqreen/capped_queue.rb +23 -0
  14. data/lib/sqreen/condition_evaluator.rb +235 -0
  15. data/lib/sqreen/conditionable.rb +50 -0
  16. data/lib/sqreen/configuration.rb +168 -0
  17. data/lib/sqreen/context.rb +26 -0
  18. data/lib/sqreen/deliveries/batch.rb +84 -0
  19. data/lib/sqreen/deliveries/simple.rb +39 -0
  20. data/lib/sqreen/event.rb +16 -0
  21. data/lib/sqreen/events/attack.rb +61 -0
  22. data/lib/sqreen/events/remote_exception.rb +54 -0
  23. data/lib/sqreen/events/request_record.rb +62 -0
  24. data/lib/sqreen/exception.rb +34 -0
  25. data/lib/sqreen/frameworks.rb +40 -0
  26. data/lib/sqreen/frameworks/generic.rb +446 -0
  27. data/lib/sqreen/frameworks/rails.rb +148 -0
  28. data/lib/sqreen/frameworks/rails3.rb +36 -0
  29. data/lib/sqreen/frameworks/request_recorder.rb +69 -0
  30. data/lib/sqreen/frameworks/sinatra.rb +57 -0
  31. data/lib/sqreen/frameworks/sqreen_test.rb +26 -0
  32. data/lib/sqreen/instrumentation.rb +542 -0
  33. data/lib/sqreen/log.rb +119 -0
  34. data/lib/sqreen/metrics.rb +6 -0
  35. data/lib/sqreen/metrics/average.rb +39 -0
  36. data/lib/sqreen/metrics/base.rb +45 -0
  37. data/lib/sqreen/metrics/collect.rb +22 -0
  38. data/lib/sqreen/metrics/sum.rb +20 -0
  39. data/lib/sqreen/metrics_store.rb +96 -0
  40. data/lib/sqreen/middleware.rb +34 -0
  41. data/lib/sqreen/payload_creator.rb +137 -0
  42. data/lib/sqreen/performance_notifications.rb +86 -0
  43. data/lib/sqreen/performance_notifications/log.rb +36 -0
  44. data/lib/sqreen/performance_notifications/metrics.rb +36 -0
  45. data/lib/sqreen/performance_notifications/newrelic.rb +36 -0
  46. data/lib/sqreen/remote_command.rb +93 -0
  47. data/lib/sqreen/rule_attributes.rb +26 -0
  48. data/lib/sqreen/rule_callback.rb +108 -0
  49. data/lib/sqreen/rules.rb +126 -0
  50. data/lib/sqreen/rules_callbacks.rb +29 -0
  51. data/lib/sqreen/rules_callbacks/binding_accessor_matcher.rb +77 -0
  52. data/lib/sqreen/rules_callbacks/binding_accessor_metrics.rb +79 -0
  53. data/lib/sqreen/rules_callbacks/blacklist_ips.rb +44 -0
  54. data/lib/sqreen/rules_callbacks/count_http_codes.rb +40 -0
  55. data/lib/sqreen/rules_callbacks/crawler_user_agent_matches.rb +24 -0
  56. data/lib/sqreen/rules_callbacks/crawler_user_agent_matches_metrics.rb +24 -0
  57. data/lib/sqreen/rules_callbacks/custom_error.rb +64 -0
  58. data/lib/sqreen/rules_callbacks/execjs.rb +241 -0
  59. data/lib/sqreen/rules_callbacks/headers_insert.rb +22 -0
  60. data/lib/sqreen/rules_callbacks/inspect_rule.rb +25 -0
  61. data/lib/sqreen/rules_callbacks/matcher_rule.rb +138 -0
  62. data/lib/sqreen/rules_callbacks/rails_parameters.rb +14 -0
  63. data/lib/sqreen/rules_callbacks/record_request_context.rb +39 -0
  64. data/lib/sqreen/rules_callbacks/reflected_xss.rb +254 -0
  65. data/lib/sqreen/rules_callbacks/regexp_rule.rb +36 -0
  66. data/lib/sqreen/rules_callbacks/shell_env.rb +32 -0
  67. data/lib/sqreen/rules_callbacks/url_matches.rb +25 -0
  68. data/lib/sqreen/rules_callbacks/user_agent_matches.rb +22 -0
  69. data/lib/sqreen/rules_signature.rb +151 -0
  70. data/lib/sqreen/runner.rb +365 -0
  71. data/lib/sqreen/runtime_infos.rb +138 -0
  72. data/lib/sqreen/safe_json.rb +60 -0
  73. data/lib/sqreen/sdk.rb +22 -0
  74. data/lib/sqreen/serializer.rb +46 -0
  75. data/lib/sqreen/session.rb +317 -0
  76. data/lib/sqreen/shared_storage.rb +31 -0
  77. data/lib/sqreen/stats.rb +18 -0
  78. data/lib/sqreen/version.rb +5 -0
  79. metadata +148 -0
@@ -0,0 +1,31 @@
1
+ # Copyright (c) 2015 Sqreen. All Rights Reserved.
2
+ # Please refer to our terms for more information: https://www.sqreen.io/terms.html
3
+
4
+ module Sqreen
5
+ module SharedStorage
6
+
7
+ def self::get(key, default = nil)
8
+ h = Thread.current["SQREEN_SHARED_STORAGE_#{self.object_id}"]
9
+ return h.fetch(key, default) if h
10
+ default
11
+ end
12
+
13
+ def self::set(key, obj)
14
+ Thread.current["SQREEN_SHARED_STORAGE_#{self.object_id}"] ||= {}
15
+ Thread.current["SQREEN_SHARED_STORAGE_#{self.object_id}"][key] = obj
16
+ end
17
+
18
+ def self.clear
19
+ return unless Thread.current["SQREEN_SHARED_STORAGE_#{self.object_id}"].is_a?(Hash)
20
+ Thread.current["SQREEN_SHARED_STORAGE_#{self.object_id}"].clear
21
+ end
22
+
23
+ def self.inc(value)
24
+ set(value, get(value, 0) + 1)
25
+ end
26
+
27
+ def self.dec(value)
28
+ set(value, get(value, 0) - 1)
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,18 @@
1
+ # Copyright (c) 2015 Sqreen. All Rights Reserved.
2
+ # Please refer to our terms for more information: https://www.sqreen.io/terms.html
3
+
4
+ module Sqreen
5
+ @@stats = nil
6
+
7
+ def self::stats
8
+ @@stats ||= Stats.new
9
+ end
10
+
11
+ class Stats
12
+ attr_accessor :callbacks_calls
13
+
14
+ def initialize
15
+ @callbacks_calls = 0
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,5 @@
1
+ # Copyright (c) 2015 Sqreen. All Rights Reserved.
2
+ # Please refer to our terms for more information: https://www.sqreen.io/terms.html
3
+ module Sqreen
4
+ VERSION = '1.10.0'.freeze
5
+ end
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sqreen-alt
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.10.0
5
+ platform: ruby
6
+ authors:
7
+ - Sqreen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-02-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: execjs
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.3.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.3.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: mini_racer
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.1'
41
+ description: Sqreen is a SaaS based Application protection and monitoring platform
42
+ that integrates directly into your Ruby applications. Learn more at https://sqreen.io.
43
+ email: contact@sqreen.io
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - CODE_OF_CONDUCT.md
49
+ - README.md
50
+ - Rakefile
51
+ - lib/sqreen-alt.rb
52
+ - lib/sqreen.rb
53
+ - lib/sqreen/attack_detected.html
54
+ - lib/sqreen/binding_accessor.rb
55
+ - lib/sqreen/ca.crt
56
+ - lib/sqreen/call_countable.rb
57
+ - lib/sqreen/callback_tree.rb
58
+ - lib/sqreen/callbacks.rb
59
+ - lib/sqreen/capped_queue.rb
60
+ - lib/sqreen/condition_evaluator.rb
61
+ - lib/sqreen/conditionable.rb
62
+ - lib/sqreen/configuration.rb
63
+ - lib/sqreen/context.rb
64
+ - lib/sqreen/deliveries/batch.rb
65
+ - lib/sqreen/deliveries/simple.rb
66
+ - lib/sqreen/event.rb
67
+ - lib/sqreen/events/attack.rb
68
+ - lib/sqreen/events/remote_exception.rb
69
+ - lib/sqreen/events/request_record.rb
70
+ - lib/sqreen/exception.rb
71
+ - lib/sqreen/frameworks.rb
72
+ - lib/sqreen/frameworks/generic.rb
73
+ - lib/sqreen/frameworks/rails.rb
74
+ - lib/sqreen/frameworks/rails3.rb
75
+ - lib/sqreen/frameworks/request_recorder.rb
76
+ - lib/sqreen/frameworks/sinatra.rb
77
+ - lib/sqreen/frameworks/sqreen_test.rb
78
+ - lib/sqreen/instrumentation.rb
79
+ - lib/sqreen/log.rb
80
+ - lib/sqreen/metrics.rb
81
+ - lib/sqreen/metrics/average.rb
82
+ - lib/sqreen/metrics/base.rb
83
+ - lib/sqreen/metrics/collect.rb
84
+ - lib/sqreen/metrics/sum.rb
85
+ - lib/sqreen/metrics_store.rb
86
+ - lib/sqreen/middleware.rb
87
+ - lib/sqreen/payload_creator.rb
88
+ - lib/sqreen/performance_notifications.rb
89
+ - lib/sqreen/performance_notifications/log.rb
90
+ - lib/sqreen/performance_notifications/metrics.rb
91
+ - lib/sqreen/performance_notifications/newrelic.rb
92
+ - lib/sqreen/remote_command.rb
93
+ - lib/sqreen/rule_attributes.rb
94
+ - lib/sqreen/rule_callback.rb
95
+ - lib/sqreen/rules.rb
96
+ - lib/sqreen/rules_callbacks.rb
97
+ - lib/sqreen/rules_callbacks/binding_accessor_matcher.rb
98
+ - lib/sqreen/rules_callbacks/binding_accessor_metrics.rb
99
+ - lib/sqreen/rules_callbacks/blacklist_ips.rb
100
+ - lib/sqreen/rules_callbacks/count_http_codes.rb
101
+ - lib/sqreen/rules_callbacks/crawler_user_agent_matches.rb
102
+ - lib/sqreen/rules_callbacks/crawler_user_agent_matches_metrics.rb
103
+ - lib/sqreen/rules_callbacks/custom_error.rb
104
+ - lib/sqreen/rules_callbacks/execjs.rb
105
+ - lib/sqreen/rules_callbacks/headers_insert.rb
106
+ - lib/sqreen/rules_callbacks/inspect_rule.rb
107
+ - lib/sqreen/rules_callbacks/matcher_rule.rb
108
+ - lib/sqreen/rules_callbacks/rails_parameters.rb
109
+ - lib/sqreen/rules_callbacks/record_request_context.rb
110
+ - lib/sqreen/rules_callbacks/reflected_xss.rb
111
+ - lib/sqreen/rules_callbacks/regexp_rule.rb
112
+ - lib/sqreen/rules_callbacks/shell_env.rb
113
+ - lib/sqreen/rules_callbacks/url_matches.rb
114
+ - lib/sqreen/rules_callbacks/user_agent_matches.rb
115
+ - lib/sqreen/rules_signature.rb
116
+ - lib/sqreen/runner.rb
117
+ - lib/sqreen/runtime_infos.rb
118
+ - lib/sqreen/safe_json.rb
119
+ - lib/sqreen/sdk.rb
120
+ - lib/sqreen/serializer.rb
121
+ - lib/sqreen/session.rb
122
+ - lib/sqreen/shared_storage.rb
123
+ - lib/sqreen/stats.rb
124
+ - lib/sqreen/version.rb
125
+ homepage: https://www.sqreen.io/
126
+ licenses: []
127
+ metadata: {}
128
+ post_install_message:
129
+ rdoc_options: []
130
+ require_paths:
131
+ - lib
132
+ required_ruby_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ requirements: []
143
+ rubyforge_project:
144
+ rubygems_version: 2.7.5
145
+ signing_key:
146
+ specification_version: 4
147
+ summary: Sqreen Ruby agent
148
+ test_files: []