omamori 0.1.2 → 0.2.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 +4 -4
- data/CHANGELOG.md +25 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +34 -14
- data/README.md +202 -49
- data/README_ja.md +204 -46
- data/demo/ai_analysis_vulnerability.rb +3 -3
- data/demo/csrf_vulnerability.rb +1 -1
- data/demo/eval_vulnerability.rb +1 -1
- data/demo/idor_vulnerability.rb +2 -2
- data/demo/insecure_cookie_vulnerability.rb +1 -1
- data/demo/open_redirect_vulnerability.rb +1 -1
- data/demo/static_analysis_vulnerability.rb +1 -1
- data/demo/xss_vulnerability.rb +1 -1
- data/exe/omamori +2 -2
- data/lib/omamori/ai_analysis_engine/checklist_scanner.rb +143 -0
- data/lib/omamori/ai_analysis_engine/cli_clients/base.rb +43 -0
- data/lib/omamori/ai_analysis_engine/cli_clients/claude_code_client.rb +35 -0
- data/lib/omamori/ai_analysis_engine/cli_clients/codex_client.rb +47 -0
- data/lib/omamori/ai_analysis_engine/diff_splitter.rb +30 -22
- data/lib/omamori/ai_analysis_engine/fallback_client.rb +23 -0
- data/lib/omamori/ai_analysis_engine/judge_client.rb +45 -0
- data/lib/omamori/ai_analysis_engine/llm_client.rb +71 -0
- data/lib/omamori/ai_analysis_engine/prompt_manager.rb +96 -19
- data/lib/omamori/ai_analysis_engine/ruby_llm_context.rb +23 -0
- data/lib/omamori/ai_analysis_engine/sub_checks/audit_log_missing.yml +12 -0
- data/lib/omamori/ai_analysis_engine/sub_checks/csrf.yml +22 -0
- data/lib/omamori/ai_analysis_engine/sub_checks/insecure_deserialization_rce.yml +9 -0
- data/lib/omamori/ai_analysis_engine/sub_checks/insufficient_encryption.yml +19 -0
- data/lib/omamori/ai_analysis_engine/sub_checks/mass_assignment.yml +19 -0
- data/lib/omamori/ai_analysis_engine/sub_checks/open_redirect.yml +17 -0
- data/lib/omamori/ai_analysis_engine/sub_checks/sql_injection.yml +20 -0
- data/lib/omamori/ai_analysis_engine/sub_checks/xss.yml +37 -0
- data/lib/omamori/ai_settings.rb +273 -0
- data/lib/omamori/config.rb +89 -69
- data/lib/omamori/core_runner.rb +485 -286
- data/lib/omamori/doctor.rb +95 -0
- data/lib/omamori/parallel.rb +24 -0
- data/lib/omamori/report_generator/console_formatter.rb +48 -42
- data/lib/omamori/report_generator/html_formatter.rb +6 -6
- data/lib/omamori/report_generator/json_formatter.rb +1 -1
- data/lib/omamori/setup_files.rb +260 -0
- data/lib/omamori/static_analysers/brakeman_runner.rb +7 -7
- data/lib/omamori/static_analysers/bundler_audit_runner.rb +8 -6
- data/lib/omamori/version.rb +2 -2
- data/lib/omamori.rb +11 -11
- metadata +61 -14
- data/lib/omamori/ai_analysis_engine/gemini_client.rb +0 -71
data/lib/omamori.rb
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative
|
|
4
|
-
require_relative
|
|
5
|
-
require_relative
|
|
6
|
-
require_relative
|
|
7
|
-
require_relative
|
|
8
|
-
require_relative
|
|
9
|
-
require_relative
|
|
10
|
-
require_relative
|
|
11
|
-
require_relative
|
|
12
|
-
require_relative
|
|
3
|
+
require_relative 'omamori/version'
|
|
4
|
+
require_relative 'omamori/core_runner'
|
|
5
|
+
require_relative 'omamori/ai_analysis_engine/llm_client'
|
|
6
|
+
require_relative 'omamori/ai_analysis_engine/prompt_manager'
|
|
7
|
+
require_relative 'omamori/ai_analysis_engine/diff_splitter'
|
|
8
|
+
require_relative 'omamori/report_generator/console_formatter'
|
|
9
|
+
require_relative 'omamori/report_generator/html_formatter'
|
|
10
|
+
require_relative 'omamori/report_generator/json_formatter'
|
|
11
|
+
require_relative 'omamori/static_analysers/brakeman_runner'
|
|
12
|
+
require_relative 'omamori/static_analysers/bundler_audit_runner'
|
|
13
13
|
|
|
14
14
|
module Omamori
|
|
15
15
|
# Your code goes here...
|
|
16
|
-
end
|
|
16
|
+
end
|
metadata
CHANGED
|
@@ -1,15 +1,42 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: omamori
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- rira100000000
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: brakeman
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - "~>"
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '7.0'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - "~>"
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '7.0'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: bundler-audit
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - "~>"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: 0.9.2
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - "~>"
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: 0.9.2
|
|
13
40
|
- !ruby/object:Gem::Dependency
|
|
14
41
|
name: colorize
|
|
15
42
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -39,19 +66,19 @@ dependencies:
|
|
|
39
66
|
- !ruby/object:Gem::Version
|
|
40
67
|
version: '2.0'
|
|
41
68
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
69
|
+
name: ruby_llm
|
|
43
70
|
requirement: !ruby/object:Gem::Requirement
|
|
44
71
|
requirements:
|
|
45
72
|
- - "~>"
|
|
46
73
|
- !ruby/object:Gem::Version
|
|
47
|
-
version:
|
|
74
|
+
version: '2.1'
|
|
48
75
|
type: :runtime
|
|
49
76
|
prerelease: false
|
|
50
77
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
78
|
requirements:
|
|
52
79
|
- - "~>"
|
|
53
80
|
- !ruby/object:Gem::Version
|
|
54
|
-
version:
|
|
81
|
+
version: '2.1'
|
|
55
82
|
- !ruby/object:Gem::Dependency
|
|
56
83
|
name: bundler
|
|
57
84
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -108,8 +135,9 @@ dependencies:
|
|
|
108
135
|
- - "~>"
|
|
109
136
|
- !ruby/object:Gem::Version
|
|
110
137
|
version: '1.0'
|
|
111
|
-
description: omamori scans Ruby code and diffs using AI (
|
|
112
|
-
|
|
138
|
+
description: omamori scans Ruby code and diffs using AI (any LLM via RubyLLM, fast
|
|
139
|
+
decision models such as Jev, or Claude Code / Codex) to detect security vulnerabilities
|
|
140
|
+
often missed by traditional tools.
|
|
113
141
|
email:
|
|
114
142
|
- 101010hayakawa@gmail
|
|
115
143
|
executables:
|
|
@@ -117,6 +145,7 @@ executables:
|
|
|
117
145
|
extensions: []
|
|
118
146
|
extra_rdoc_files: []
|
|
119
147
|
files:
|
|
148
|
+
- CHANGELOG.md
|
|
120
149
|
- Gemfile
|
|
121
150
|
- Gemfile.lock
|
|
122
151
|
- LICENSE
|
|
@@ -132,25 +161,44 @@ files:
|
|
|
132
161
|
- demo/xss_vulnerability.rb
|
|
133
162
|
- exe/omamori
|
|
134
163
|
- lib/omamori.rb
|
|
164
|
+
- lib/omamori/ai_analysis_engine/checklist_scanner.rb
|
|
165
|
+
- lib/omamori/ai_analysis_engine/cli_clients/base.rb
|
|
166
|
+
- lib/omamori/ai_analysis_engine/cli_clients/claude_code_client.rb
|
|
167
|
+
- lib/omamori/ai_analysis_engine/cli_clients/codex_client.rb
|
|
135
168
|
- lib/omamori/ai_analysis_engine/diff_splitter.rb
|
|
136
|
-
- lib/omamori/ai_analysis_engine/
|
|
169
|
+
- lib/omamori/ai_analysis_engine/fallback_client.rb
|
|
170
|
+
- lib/omamori/ai_analysis_engine/judge_client.rb
|
|
171
|
+
- lib/omamori/ai_analysis_engine/llm_client.rb
|
|
137
172
|
- lib/omamori/ai_analysis_engine/prompt_manager.rb
|
|
173
|
+
- lib/omamori/ai_analysis_engine/ruby_llm_context.rb
|
|
174
|
+
- lib/omamori/ai_analysis_engine/sub_checks/audit_log_missing.yml
|
|
175
|
+
- lib/omamori/ai_analysis_engine/sub_checks/csrf.yml
|
|
176
|
+
- lib/omamori/ai_analysis_engine/sub_checks/insecure_deserialization_rce.yml
|
|
177
|
+
- lib/omamori/ai_analysis_engine/sub_checks/insufficient_encryption.yml
|
|
178
|
+
- lib/omamori/ai_analysis_engine/sub_checks/mass_assignment.yml
|
|
179
|
+
- lib/omamori/ai_analysis_engine/sub_checks/open_redirect.yml
|
|
180
|
+
- lib/omamori/ai_analysis_engine/sub_checks/sql_injection.yml
|
|
181
|
+
- lib/omamori/ai_analysis_engine/sub_checks/xss.yml
|
|
182
|
+
- lib/omamori/ai_settings.rb
|
|
138
183
|
- lib/omamori/config.rb
|
|
139
184
|
- lib/omamori/core_runner.rb
|
|
185
|
+
- lib/omamori/doctor.rb
|
|
186
|
+
- lib/omamori/parallel.rb
|
|
140
187
|
- lib/omamori/report_generator/console_formatter.rb
|
|
141
188
|
- lib/omamori/report_generator/html_formatter.rb
|
|
142
189
|
- lib/omamori/report_generator/json_formatter.rb
|
|
143
190
|
- lib/omamori/report_generator/report_template.erb
|
|
191
|
+
- lib/omamori/setup_files.rb
|
|
144
192
|
- lib/omamori/static_analysers/brakeman_runner.rb
|
|
145
193
|
- lib/omamori/static_analysers/bundler_audit_runner.rb
|
|
146
194
|
- lib/omamori/version.rb
|
|
147
195
|
homepage: https://github.com/rira100000000/omamori
|
|
148
|
-
licenses:
|
|
196
|
+
licenses:
|
|
197
|
+
- MIT
|
|
149
198
|
metadata:
|
|
150
199
|
homepage_uri: https://github.com/rira100000000/omamori
|
|
151
200
|
source_code_uri: https://github.com/rira100000000/omamori
|
|
152
201
|
changelog_uri: https://github.com/rira100000000/omamori/blob/main/CHANGELOG.md
|
|
153
|
-
post_install_message:
|
|
154
202
|
rdoc_options: []
|
|
155
203
|
require_paths:
|
|
156
204
|
- lib
|
|
@@ -158,15 +206,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
158
206
|
requirements:
|
|
159
207
|
- - ">="
|
|
160
208
|
- !ruby/object:Gem::Version
|
|
161
|
-
version: '
|
|
209
|
+
version: '3.2'
|
|
162
210
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
211
|
requirements:
|
|
164
212
|
- - ">="
|
|
165
213
|
- !ruby/object:Gem::Version
|
|
166
214
|
version: '0'
|
|
167
215
|
requirements: []
|
|
168
|
-
rubygems_version: 3.
|
|
169
|
-
signing_key:
|
|
216
|
+
rubygems_version: 3.6.9
|
|
170
217
|
specification_version: 4
|
|
171
218
|
summary: AI-powered security vulnerability scanner for Ruby projects.
|
|
172
219
|
test_files: []
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'gemini'
|
|
4
|
-
|
|
5
|
-
module Omamori
|
|
6
|
-
module AIAnalysisEngine
|
|
7
|
-
class GeminiClient
|
|
8
|
-
def initialize(api_key)
|
|
9
|
-
@api_key = api_key || ENV["GEMINI_API_KEY"]
|
|
10
|
-
@client = nil # Initialize client later
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def analyze(prompt, json_schema, model: "gemini-1.5-pro-latest")
|
|
14
|
-
# Ensure the client is initialized
|
|
15
|
-
client
|
|
16
|
-
|
|
17
|
-
begin
|
|
18
|
-
response = @client.generate_content(
|
|
19
|
-
prompt,
|
|
20
|
-
model: model,
|
|
21
|
-
response_schema: json_schema, # Use response_schema for Structured Output
|
|
22
|
-
temperature: 0.0
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
# Debug: Inspect the response object
|
|
26
|
-
# puts "Debug: response object: #{response.inspect}"
|
|
27
|
-
# puts "Debug: response methods: #{response.methods.sort}"
|
|
28
|
-
|
|
29
|
-
# Extract and parse JSON from the response text
|
|
30
|
-
json_string = response.text.gsub(/\A```json\n|```\z/, '').strip
|
|
31
|
-
begin
|
|
32
|
-
parsed_response = JSON.parse(json_string)
|
|
33
|
-
# Validate the parsed output structure
|
|
34
|
-
if parsed_response.is_a?(Hash) && parsed_response.key?('security_risks')
|
|
35
|
-
# Return the parsed JSON data
|
|
36
|
-
parsed_response
|
|
37
|
-
else
|
|
38
|
-
puts "Warning: Unexpected AI analysis response structure."
|
|
39
|
-
puts "Raw response text: #{response.text}"
|
|
40
|
-
nil # Return nil if the structure is unexpected
|
|
41
|
-
end
|
|
42
|
-
rescue JSON::ParserError
|
|
43
|
-
puts "Warning: Failed to parse response text as JSON."
|
|
44
|
-
puts "Raw response text: #{response.text}"
|
|
45
|
-
nil # Or handle the error appropriately
|
|
46
|
-
end
|
|
47
|
-
rescue Faraday::Error => e
|
|
48
|
-
puts "API Error: #{e.message}"
|
|
49
|
-
puts "Response body: #{e.response[:body]}" if e.response
|
|
50
|
-
nil # Handle API errors
|
|
51
|
-
rescue => e
|
|
52
|
-
puts "An unexpected error occurred during API call: #{e.message}"
|
|
53
|
-
nil # Handle other errors
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
private
|
|
58
|
-
|
|
59
|
-
def client
|
|
60
|
-
@client ||= begin
|
|
61
|
-
# Configure the client with the API key
|
|
62
|
-
Gemini.configure do |config|
|
|
63
|
-
config.api_key = @api_key
|
|
64
|
-
end
|
|
65
|
-
# Create a new client instance
|
|
66
|
-
Gemini::Client.new
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
end
|