pwn 0.5.436 → 0.5.438

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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -3
  3. data/lib/pwn/ai/introspection.rb +0 -1
  4. data/lib/pwn/reports/sast.rb +50 -58
  5. data/lib/pwn/sast/amqp_connect_as_guest.rb +19 -2
  6. data/lib/pwn/sast/apache_file_system_util_api.rb +19 -2
  7. data/lib/pwn/sast/aws.rb +19 -2
  8. data/lib/pwn/sast/banned_function_calls_c.rb +19 -2
  9. data/lib/pwn/sast/base64.rb +19 -2
  10. data/lib/pwn/sast/beef_hook.rb +19 -2
  11. data/lib/pwn/sast/cmd_execution_java.rb +19 -2
  12. data/lib/pwn/sast/cmd_execution_python.rb +19 -2
  13. data/lib/pwn/sast/cmd_execution_ruby.rb +19 -2
  14. data/lib/pwn/sast/cmd_execution_scala.rb +19 -2
  15. data/lib/pwn/sast/csrf.rb +19 -2
  16. data/lib/pwn/sast/deserial_java.rb +19 -2
  17. data/lib/pwn/sast/emoticon.rb +19 -2
  18. data/lib/pwn/sast/eval.rb +19 -2
  19. data/lib/pwn/sast/factory.rb +19 -2
  20. data/lib/pwn/sast/http_authorization_header.rb +19 -2
  21. data/lib/pwn/sast/inner_html.rb +19 -2
  22. data/lib/pwn/sast/keystore.rb +19 -2
  23. data/lib/pwn/sast/local_storage.rb +19 -2
  24. data/lib/pwn/sast/location_hash.rb +19 -2
  25. data/lib/pwn/sast/log4j.rb +19 -2
  26. data/lib/pwn/sast/logger.rb +19 -2
  27. data/lib/pwn/sast/md5.rb +19 -2
  28. data/lib/pwn/sast/outer_html.rb +19 -2
  29. data/lib/pwn/sast/padding_oracle.rb +19 -2
  30. data/lib/pwn/sast/password.rb +19 -2
  31. data/lib/pwn/sast/php_input_mechanisms.rb +19 -2
  32. data/lib/pwn/sast/php_type_juggling.rb +19 -2
  33. data/lib/pwn/sast/pom_version.rb +19 -2
  34. data/lib/pwn/sast/port.rb +19 -2
  35. data/lib/pwn/sast/post_message.rb +19 -2
  36. data/lib/pwn/sast/private_key.rb +19 -2
  37. data/lib/pwn/sast/redirect.rb +19 -2
  38. data/lib/pwn/sast/redos.rb +19 -2
  39. data/lib/pwn/sast/shell.rb +19 -2
  40. data/lib/pwn/sast/signature.rb +19 -2
  41. data/lib/pwn/sast/sql.rb +19 -2
  42. data/lib/pwn/sast/ssl.rb +19 -2
  43. data/lib/pwn/sast/sudo.rb +19 -2
  44. data/lib/pwn/sast/task_tag.rb +19 -2
  45. data/lib/pwn/sast/throw_errors.rb +19 -2
  46. data/lib/pwn/sast/token.rb +19 -2
  47. data/lib/pwn/sast/type_script_type_juggling.rb +19 -2
  48. data/lib/pwn/sast/version.rb +19 -2
  49. data/lib/pwn/sast/window_location_hash.rb +19 -2
  50. data/lib/pwn/version.rb +1 -1
  51. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b0b70877101aefea31cdfd2b5eeb0ad3828273814199faf10e2c52fe35a6455
4
- data.tar.gz: ad68a9d8e4a114096a062812cedf20813d34d6bc91f210884b54ac838ed6219b
3
+ metadata.gz: 39ca9fea12099970f21ae015c6f813c3477c8578e2064020a316a3f27cf8cdd6
4
+ data.tar.gz: fef34d6fabcf175ea6c11e82eed213e382e7cf2e30d56635723e179664d850a8
5
5
  SHA512:
6
- metadata.gz: 4b4721af1d836061595b1c295100927d2824c19e68ce0f17edec6dd07e707cbf5f01dcc7ca0d697803547b2ecc64a2b527936a7e5f86d7d4ba2f3d44e6ada0e3
7
- data.tar.gz: f0eea79fb719f06556c8b6260181c5dd25067cba7c4e8d800bc3c543b61e05a45907a22add4e73d6b63b3db04771c31e90793344e8d9f3d1da49f0ce2bbd4ac8
6
+ metadata.gz: 4eeba1332208ccaa0ca9dad210d179e335bcb4dd33c51641da5178e781b7be6d9bafc0ac18a14c79da098f0494b0e335fffee0ba0c7e9be36a8a4e062dc40d6c
7
+ data.tar.gz: 217606280373257ec6ee318ac34bf4acfa7e4b92ef1b03876efeb9a492d7006ad5d0066670bfdeb64886c81ab449aba75f525bf9223f5641dd1aa752321a791e
data/README.md CHANGED
@@ -37,7 +37,7 @@ $ cd /opt/pwn
37
37
  $ ./install.sh
38
38
  $ ./install.sh ruby-gem
39
39
  $ pwn
40
- pwn[v0.5.436]:001 >>> PWN.help
40
+ pwn[v0.5.438]:001 >>> PWN.help
41
41
  ```
42
42
 
43
43
  [![Installing the pwn Security Automation Framework](https://raw.githubusercontent.com/0dayInc/pwn/master/documentation/pwn_install.png)](https://youtu.be/G7iLUY4FzsI)
@@ -52,7 +52,7 @@ $ rvm use ruby-3.4.4@pwn
52
52
  $ gem uninstall --all --executables pwn
53
53
  $ gem install --verbose pwn
54
54
  $ pwn
55
- pwn[v0.5.436]:001 >>> PWN.help
55
+ pwn[v0.5.438]:001 >>> PWN.help
56
56
  ```
57
57
 
58
58
  If you're using a multi-user install of RVM do:
@@ -62,7 +62,7 @@ $ rvm use ruby-3.4.4@pwn
62
62
  $ rvmsudo gem uninstall --all --executables pwn
63
63
  $ rvmsudo gem install --verbose pwn
64
64
  $ pwn
65
- pwn[v0.5.436]:001 >>> PWN.help
65
+ pwn[v0.5.438]:001 >>> PWN.help
66
66
  ```
67
67
 
68
68
  PWN periodically upgrades to the latest version of Ruby which is reflected in `/opt/pwn/.ruby-version`. The easiest way to upgrade to the latest version of Ruby from a previous PWN installation is to run the following script:
@@ -2,7 +2,6 @@
2
2
 
3
3
  require 'json'
4
4
  require 'rest-client'
5
- require 'tty-spinner'
6
5
 
7
6
  module PWN
8
7
  module AI
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'json'
4
- require 'tty-spinner'
5
4
 
6
5
  module PWN
7
6
  module Reports
@@ -25,62 +24,55 @@ module PWN
25
24
  }
26
25
  report_name = opts[:report_name] ||= File.basename(Dir.pwd)
27
26
 
28
- ai_instrospection = PWN::Env[:ai][:introspection]
29
- puts "Analyzing source code using AI engine: #{engine}\nModel: #{model}\nSystem Role Content: #{system_role_content}\nTemperature: #{temp}" if ai_instrospection
30
-
31
27
  # Calculate percentage of AI analysis based on the number of entries
32
- total_entries = results_hash[:data].sum { |entry| entry[:line_no_and_contents].size }
33
- puts "Total entries to analyze: #{total_entries}" if engine
34
-
35
- percent_complete = 0.0
36
- entry_count = 0
37
- spin = TTY::Spinner.new(
38
- '[:spinner] Report Generation Progress: :percent_complete :entry_count of :total_entries',
39
- format: :dots,
40
- hide_cursor: true
41
- )
42
- spin.auto_spin
43
-
44
- results_hash[:data].each do |hash_line|
45
- git_repo_root_uri = hash_line[:filename][:git_repo_root_uri]
46
- filename = hash_line[:filename][:entry]
47
- hash_line[:line_no_and_contents].each do |src_detail|
48
- entry_count += 1
49
- percent_complete = (entry_count.to_f / total_entries * 100).round(2)
50
- line_no = src_detail[:line_no]
51
- source_code_snippet = src_detail[:contents]
52
- author = src_detail[:author].to_s.scrub.chomp.strip
53
-
54
- # TODO: >>>
55
- # 1. Move PWN::AI::Introspection.reflect into each PWN::SAST::* module
56
- # This will drastically speed up the overall SAST analysis process
57
- # 2. Have PWN::AI::Introspection.reflect assess test case effectiveness
58
- response = nil
59
- if ai_instrospection
60
- request = {
61
- scm_uri: "#{git_repo_root_uri}/#{filename}",
62
- line: line_no,
63
- source_code_snippet: source_code_snippet
64
- }.to_json
65
- response = PWN::AI::Introspection.reflect(request: request)
66
- end
67
-
68
- ai_analysis = nil
69
- if response.is_a?(Hash)
70
- ai_analysis = response[:choices].last[:text] if response[:choices].last.keys.include?(:text)
71
- ai_analysis = response[:choices].last[:content] if response[:choices].last.keys.include?(:content)
72
- # puts "AI Analysis Progress: #{percent_complete}% Line: #{line_no} | Author: #{author} | AI Analysis: #{ai_analysis}\n\n\n" if ai_analysis
73
- end
74
- # TODO: Make results prettier in the HTML report
75
- src_detail[:ai_analysis] = ai_analysis.to_s.scrub.chomp.strip
76
-
77
- spin.update(
78
- percent_complete: "#{percent_complete}%",
79
- entry_count: entry_count,
80
- total_entries: total_entries
81
- )
82
- end
83
- end
28
+ # total_entries = results_hash[:data].sum { |entry| entry[:line_no_and_contents].size }
29
+ # puts "Total entries to analyze: #{total_entries}" if engine
30
+
31
+ # percent_complete = 0.0
32
+ # entry_count = 0
33
+ # spin = TTY::Spinner.new(
34
+ # '[:spinner] Report Generation Progress: :percent_complete :entry_count of :total_entries',
35
+ # format: :dots,
36
+ # hide_cursor: true
37
+ # )
38
+ # spin.auto_spin
39
+
40
+ # ai_instrospection = PWN::Env[:ai][:introspection]
41
+ # puts "Analyzing source code using AI engine: #{engine}\nModel: #{model}\nSystem Role Content: #{system_role_content}\nTemperature: #{temp}" if ai_instrospection
42
+
43
+ # results_hash[:data].each do |hash_line|
44
+ # git_repo_root_uri = hash_line[:filename][:git_repo_root_uri]
45
+ # filename = hash_line[:filename][:entry]
46
+ # hash_line[:line_no_and_contents].each do |src_detail|
47
+ # entry_count += 1
48
+ # percent_complete = (entry_count.to_f / total_entries * 100).round(2)
49
+ # line_no = src_detail[:line_no]
50
+ # source_code_snippet = src_detail[:contents]
51
+ # author = src_detail[:author].to_s.scrub.chomp.strip
52
+ # response = nil
53
+ # if ai_instrospection
54
+ # request = {
55
+ # scm_uri: "#{git_repo_root_uri}/#{filename}",
56
+ # line: line_no,
57
+ # source_code_snippet: source_code_snippet
58
+ # }.to_json
59
+ # response = PWN::AI::Introspection.reflect(request: request)
60
+ # end
61
+ # ai_analysis = nil
62
+ # if response.is_a?(Hash)
63
+ # ai_analysis = response[:choices].last[:text] if response[:choices].last.keys.include?(:text)
64
+ # ai_analysis = response[:choices].last[:content] if response[:choices].last.keys.include?(:content)
65
+ # puts "AI Analysis Progress: #{percent_complete}% Line: #{line_no} | Author: #{author} | AI Analysis: #{ai_analysis}\n\n\n" if ai_analysis
66
+ # end
67
+ # src_detail[:ai_analysis] = ai_analysis.to_s.scrub.chomp.strip
68
+ # spin.update(
69
+ # percent_complete: "#{percent_complete}%",
70
+ # entry_count: entry_count,
71
+ # total_entries: total_entries
72
+ # )
73
+ # end
74
+ # end
75
+
84
76
  # JSON object Completion
85
77
  # File.open("#{dir_path}/pwn_scan_git_source.json", 'w') do |f|
86
78
  # f.print(results_hash.to_json)
@@ -467,8 +459,8 @@ module PWN
467
459
  end
468
460
  rescue StandardError => e
469
461
  raise e
470
- ensure
471
- spin.stop unless spin.nil?
462
+ # ensure
463
+ # spin.stop unless spin.nil?
472
464
  end
473
465
 
474
466
  # Author(s):: 0day Inc. <support@0dayinc.com>
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: false
2
2
 
3
+ require 'json'
3
4
  require 'socket'
4
5
 
5
6
  module PWN
@@ -20,7 +21,8 @@ module PWN
20
21
  dir_path = opts[:dir_path]
21
22
  git_repo_root_uri = opts[:git_repo_root_uri].to_s.scrub
22
23
  result_arr = []
23
- logger_results = ''
24
+ ai_introspection = PWN::Env[:ai][:introspection]
25
+ logger_results = "AI Introspection => #{ai_introspection} => "
24
26
 
25
27
  PWN::Plugins::FileFu.recurse_in_dir(dir_path: dir_path) do |entry|
26
28
  if File.file?(entry) && File.basename(entry) !~ /^pwn.+(html|json|db)$/ && File.basename(entry) !~ /\.JS-BEAUTIFIED$/ && entry !~ /test/i
@@ -75,10 +77,25 @@ module PWN
75
77
  end
76
78
  author ||= 'N/A'
77
79
 
80
+ ai_analysis = nil
81
+ if ai_introspection
82
+ request = {
83
+ scm_uri: "#{hash_line[:filename][:git_repo_root_uri]}/#{hash_line[:filename][:entry]}",
84
+ line_no: line_no,
85
+ source_code_snippet: contents
86
+ }.to_json
87
+ response = PWN::AI::Introspection.reflect(request: request)
88
+ if response.is_a?(Hash)
89
+ ai_analysis = response[:choices].last[:text] if response[:choices].last.keys.include?(:text)
90
+ ai_analysis = response[:choices].last[:content] if response[:choices].last.keys.include?(:content)
91
+ end
92
+ end
93
+
78
94
  hash_line[:line_no_and_contents] = line_no_and_contents_arr.push(
79
95
  line_no: line_no,
80
96
  contents: contents,
81
- author: author
97
+ author: author,
98
+ ai_analysis: ai_analysis
82
99
  )
83
100
  current_count += 2
84
101
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: false
2
2
 
3
+ require 'json'
3
4
  require 'socket'
4
5
 
5
6
  module PWN
@@ -19,7 +20,8 @@ module PWN
19
20
  dir_path = opts[:dir_path]
20
21
  git_repo_root_uri = opts[:git_repo_root_uri].to_s.scrub
21
22
  result_arr = []
22
- logger_results = ''
23
+ ai_introspection = PWN::Env[:ai][:introspection]
24
+ logger_results = "AI Introspection => #{ai_introspection} => "
23
25
 
24
26
  PWN::Plugins::FileFu.recurse_in_dir(dir_path: dir_path) do |entry|
25
27
  if File.file?(entry) && File.basename(entry) !~ /^pwn.+(html|json|db)$/ && File.basename(entry) !~ /\.JS-BEAUTIFIED$/ && entry !~ /test/i
@@ -75,10 +77,25 @@ module PWN
75
77
  end
76
78
  author ||= 'N/A'
77
79
 
80
+ ai_analysis = nil
81
+ if ai_introspection
82
+ request = {
83
+ scm_uri: "#{hash_line[:filename][:git_repo_root_uri]}/#{hash_line[:filename][:entry]}",
84
+ line_no: line_no,
85
+ source_code_snippet: contents
86
+ }.to_json
87
+ response = PWN::AI::Introspection.reflect(request: request)
88
+ if response.is_a?(Hash)
89
+ ai_analysis = response[:choices].last[:text] if response[:choices].last.keys.include?(:text)
90
+ ai_analysis = response[:choices].last[:content] if response[:choices].last.keys.include?(:content)
91
+ end
92
+ end
93
+
78
94
  hash_line[:line_no_and_contents] = line_no_and_contents_arr.push(
79
95
  line_no: line_no,
80
96
  contents: contents,
81
- author: author
97
+ author: author,
98
+ ai_analysis: ai_analysis
82
99
  )
83
100
 
84
101
  current_count += 2
data/lib/pwn/sast/aws.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: false
2
2
 
3
+ require 'json'
3
4
  require 'socket'
4
5
 
5
6
  module PWN
@@ -18,7 +19,8 @@ module PWN
18
19
  dir_path = opts[:dir_path]
19
20
  git_repo_root_uri = opts[:git_repo_root_uri].to_s.scrub
20
21
  result_arr = []
21
- logger_results = ''
22
+ ai_introspection = PWN::Env[:ai][:introspection]
23
+ logger_results = "AI Introspection => #{ai_introspection} => "
22
24
 
23
25
  PWN::Plugins::FileFu.recurse_in_dir(dir_path: dir_path) do |entry|
24
26
  if File.file?(entry) && File.basename(entry) !~ /^pwn.+(html|json|db)$/ && File.basename(entry) !~ /\.JS-BEAUTIFIED$/ && entry !~ /test/i
@@ -76,10 +78,25 @@ module PWN
76
78
  end
77
79
  author ||= 'N/A'
78
80
 
81
+ ai_analysis = nil
82
+ if ai_introspection
83
+ request = {
84
+ scm_uri: "#{hash_line[:filename][:git_repo_root_uri]}/#{hash_line[:filename][:entry]}",
85
+ line_no: line_no,
86
+ source_code_snippet: contents
87
+ }.to_json
88
+ response = PWN::AI::Introspection.reflect(request: request)
89
+ if response.is_a?(Hash)
90
+ ai_analysis = response[:choices].last[:text] if response[:choices].last.keys.include?(:text)
91
+ ai_analysis = response[:choices].last[:content] if response[:choices].last.keys.include?(:content)
92
+ end
93
+ end
94
+
79
95
  hash_line[:line_no_and_contents] = line_no_and_contents_arr.push(
80
96
  line_no: line_no,
81
97
  contents: contents,
82
- author: author
98
+ author: author,
99
+ ai_analysis: ai_analysis
83
100
  )
84
101
 
85
102
  current_count += 2
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: false
2
2
 
3
+ require 'json'
3
4
  require 'socket'
4
5
 
5
6
  module PWN
@@ -20,7 +21,8 @@ module PWN
20
21
  dir_path = opts[:dir_path]
21
22
  git_repo_root_uri = opts[:git_repo_root_uri].to_s.scrub
22
23
  result_arr = []
23
- logger_results = ''
24
+ ai_introspection = PWN::Env[:ai][:introspection]
25
+ logger_results = "AI Introspection => #{ai_introspection} => "
24
26
 
25
27
  PWN::Plugins::FileFu.recurse_in_dir(dir_path: dir_path) do |entry|
26
28
  if (File.file?(entry) && File.basename(entry) !~ /^pwn.+(html|json|db)$/ && File.basename(entry) !~ /\.JS-BEAUTIFIED$/) && (File.extname(entry) == '.c' || File.extname(entry) == '.cpp' || File.extname(entry) == '.c++' || File.extname(entry) == '.cxx' || File.extname(entry) == '.h' || File.extname(entry) == '.hpp' || File.extname(entry) == '.h++' || File.extname(entry) == '.hh' || File.extname(entry) == '.hxx' || File.extname(entry) == '.ii' || File.extname(entry) == '.ixx' || File.extname(entry) == '.ipp' || File.extname(entry) == '.inl' || File.extname(entry) == '.txx' || File.extname(entry) == '.tpp' || File.extname(entry) == '.tpl') && entry !~ /test/i
@@ -203,10 +205,25 @@ module PWN
203
205
  end
204
206
  author ||= 'N/A'
205
207
 
208
+ ai_analysis = nil
209
+ if ai_introspection
210
+ request = {
211
+ scm_uri: "#{hash_line[:filename][:git_repo_root_uri]}/#{hash_line[:filename][:entry]}",
212
+ line_no: line_no,
213
+ source_code_snippet: contents
214
+ }.to_json
215
+ response = PWN::AI::Introspection.reflect(request: request)
216
+ if response.is_a?(Hash)
217
+ ai_analysis = response[:choices].last[:text] if response[:choices].last.keys.include?(:text)
218
+ ai_analysis = response[:choices].last[:content] if response[:choices].last.keys.include?(:content)
219
+ end
220
+ end
221
+
206
222
  hash_line[:line_no_and_contents] = line_no_and_contents_arr.push(
207
223
  line_no: line_no,
208
224
  contents: contents,
209
- author: author
225
+ author: author,
226
+ ai_analysis: ai_analysis
210
227
  )
211
228
 
212
229
  current_count += 2
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: false
2
2
 
3
+ require 'json'
3
4
  require 'socket'
4
5
 
5
6
  module PWN
@@ -19,7 +20,8 @@ module PWN
19
20
  dir_path = opts[:dir_path]
20
21
  git_repo_root_uri = opts[:git_repo_root_uri].to_s.scrub
21
22
  result_arr = []
22
- logger_results = ''
23
+ ai_introspection = PWN::Env[:ai][:introspection]
24
+ logger_results = "AI Introspection => #{ai_introspection} => "
23
25
 
24
26
  PWN::Plugins::FileFu.recurse_in_dir(dir_path: dir_path) do |entry|
25
27
  if File.file?(entry) && File.basename(entry) !~ /^pwn.+(html|json|db)$/ && File.basename(entry) !~ /\.JS-BEAUTIFIED$/ && entry !~ /test/i
@@ -74,10 +76,25 @@ module PWN
74
76
  end
75
77
  author ||= 'N/A'
76
78
 
79
+ ai_analysis = nil
80
+ if ai_introspection
81
+ request = {
82
+ scm_uri: "#{hash_line[:filename][:git_repo_root_uri]}/#{hash_line[:filename][:entry]}",
83
+ line_no: line_no,
84
+ source_code_snippet: contents
85
+ }.to_json
86
+ response = PWN::AI::Introspection.reflect(request: request)
87
+ if response.is_a?(Hash)
88
+ ai_analysis = response[:choices].last[:text] if response[:choices].last.keys.include?(:text)
89
+ ai_analysis = response[:choices].last[:content] if response[:choices].last.keys.include?(:content)
90
+ end
91
+ end
92
+
77
93
  hash_line[:line_no_and_contents] = line_no_and_contents_arr.push(
78
94
  line_no: line_no,
79
95
  contents: contents,
80
- author: author
96
+ author: author,
97
+ ai_analysis: ai_analysis
81
98
  )
82
99
 
83
100
  current_count += 2
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: false
2
2
 
3
+ require 'json'
3
4
  require 'socket'
4
5
 
5
6
  module PWN
@@ -19,7 +20,8 @@ module PWN
19
20
  dir_path = opts[:dir_path]
20
21
  git_repo_root_uri = opts[:git_repo_root_uri].to_s.scrub
21
22
  result_arr = []
22
- logger_results = ''
23
+ ai_introspection = PWN::Env[:ai][:introspection]
24
+ logger_results = "AI Introspection => #{ai_introspection} => "
23
25
 
24
26
  PWN::Plugins::FileFu.recurse_in_dir(dir_path: dir_path) do |entry|
25
27
  if File.file?(entry) && File.basename(entry) !~ /^pwn.+(html|json|db)$/ && File.basename(entry) !~ /\.JS-BEAUTIFIED$/ && entry !~ /test/i
@@ -74,10 +76,25 @@ module PWN
74
76
  end
75
77
  author ||= 'N/A'
76
78
 
79
+ ai_analysis = nil
80
+ if ai_introspection
81
+ request = {
82
+ scm_uri: "#{hash_line[:filename][:git_repo_root_uri]}/#{hash_line[:filename][:entry]}",
83
+ line_no: line_no,
84
+ source_code_snippet: contents
85
+ }.to_json
86
+ response = PWN::AI::Introspection.reflect(request: request)
87
+ if response.is_a?(Hash)
88
+ ai_analysis = response[:choices].last[:text] if response[:choices].last.keys.include?(:text)
89
+ ai_analysis = response[:choices].last[:content] if response[:choices].last.keys.include?(:content)
90
+ end
91
+ end
92
+
77
93
  hash_line[:line_no_and_contents] = line_no_and_contents_arr.push(
78
94
  line_no: line_no,
79
95
  contents: contents,
80
- author: author
96
+ author: author,
97
+ ai_analysis: ai_analysis
81
98
  )
82
99
 
83
100
  current_count += 2
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: false
2
2
 
3
+ require 'json'
3
4
  require 'socket'
4
5
 
5
6
  module PWN
@@ -19,7 +20,8 @@ module PWN
19
20
  dir_path = opts[:dir_path]
20
21
  git_repo_root_uri = opts[:git_repo_root_uri].to_s.scrub
21
22
  result_arr = []
22
- logger_results = ''
23
+ ai_introspection = PWN::Env[:ai][:introspection]
24
+ logger_results = "AI Introspection => #{ai_introspection} => "
23
25
 
24
26
  PWN::Plugins::FileFu.recurse_in_dir(dir_path: dir_path) do |entry|
25
27
  if (File.file?(entry) && File.basename(entry) !~ /^pwn.+(html|json|db)$/ && File.basename(entry) !~ /\.JS-BEAUTIFIED$/) && File.extname(entry) == '.java' && entry !~ /test/i
@@ -76,10 +78,25 @@ module PWN
76
78
  end
77
79
  author ||= 'N/A'
78
80
 
81
+ ai_analysis = nil
82
+ if ai_introspection
83
+ request = {
84
+ scm_uri: "#{hash_line[:filename][:git_repo_root_uri]}/#{hash_line[:filename][:entry]}",
85
+ line_no: line_no,
86
+ source_code_snippet: contents
87
+ }.to_json
88
+ response = PWN::AI::Introspection.reflect(request: request)
89
+ if response.is_a?(Hash)
90
+ ai_analysis = response[:choices].last[:text] if response[:choices].last.keys.include?(:text)
91
+ ai_analysis = response[:choices].last[:content] if response[:choices].last.keys.include?(:content)
92
+ end
93
+ end
94
+
79
95
  hash_line[:line_no_and_contents] = line_no_and_contents_arr.push(
80
96
  line_no: line_no,
81
97
  contents: contents,
82
- author: author
98
+ author: author,
99
+ ai_analysis: ai_analysis
83
100
  )
84
101
 
85
102
  current_count += 2
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: false
2
2
 
3
+ require 'json'
3
4
  require 'socket'
4
5
 
5
6
  module PWN
@@ -19,7 +20,8 @@ module PWN
19
20
  dir_path = opts[:dir_path]
20
21
  git_repo_root_uri = opts[:git_repo_root_uri].to_s.scrub
21
22
  result_arr = []
22
- logger_results = ''
23
+ ai_introspection = PWN::Env[:ai][:introspection]
24
+ logger_results = "AI Introspection => #{ai_introspection} => "
23
25
 
24
26
  PWN::Plugins::FileFu.recurse_in_dir(dir_path: dir_path) do |entry|
25
27
  if (File.file?(entry) && File.basename(entry) !~ /^pwn.+(html|json|db)$/ && File.basename(entry) !~ /\.JS-BEAUTIFIED$/) && (File.extname(entry) == '.py' || File.extname(entry) == '.pyc' || File.extname(entry) == '.pyo' || File.extname(entry) == '.pyd') && entry !~ /test/i
@@ -78,10 +80,25 @@ module PWN
78
80
  end
79
81
  author ||= 'N/A'
80
82
 
83
+ ai_analysis = nil
84
+ if ai_introspection
85
+ request = {
86
+ scm_uri: "#{hash_line[:filename][:git_repo_root_uri]}/#{hash_line[:filename][:entry]}",
87
+ line_no: line_no,
88
+ source_code_snippet: contents
89
+ }.to_json
90
+ response = PWN::AI::Introspection.reflect(request: request)
91
+ if response.is_a?(Hash)
92
+ ai_analysis = response[:choices].last[:text] if response[:choices].last.keys.include?(:text)
93
+ ai_analysis = response[:choices].last[:content] if response[:choices].last.keys.include?(:content)
94
+ end
95
+ end
96
+
81
97
  hash_line[:line_no_and_contents] = line_no_and_contents_arr.push(
82
98
  line_no: line_no,
83
99
  contents: contents,
84
- author: author
100
+ author: author,
101
+ ai_analysis: ai_analysis
85
102
  )
86
103
 
87
104
  current_count += 2
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: false
2
2
 
3
+ require 'json'
3
4
  require 'socket'
4
5
 
5
6
  module PWN
@@ -19,7 +20,8 @@ module PWN
19
20
  dir_path = opts[:dir_path]
20
21
  git_repo_root_uri = opts[:git_repo_root_uri].to_s.scrub
21
22
  result_arr = []
22
- logger_results = ''
23
+ ai_introspection = PWN::Env[:ai][:introspection]
24
+ logger_results = "AI Introspection => #{ai_introspection} => "
23
25
 
24
26
  PWN::Plugins::FileFu.recurse_in_dir(dir_path: dir_path) do |entry|
25
27
  if (File.file?(entry) && File.basename(entry) !~ /^pwn.+(html|json|db)$/ && File.basename(entry) !~ /\.JS-BEAUTIFIED$/) && (File.extname(entry) == '.rb' || File.extname(entry) == '.rbw') && entry !~ /test/i
@@ -86,10 +88,25 @@ module PWN
86
88
  end
87
89
  author ||= 'N/A'
88
90
 
91
+ ai_analysis = nil
92
+ if ai_introspection
93
+ request = {
94
+ scm_uri: "#{hash_line[:filename][:git_repo_root_uri]}/#{hash_line[:filename][:entry]}",
95
+ line_no: line_no,
96
+ source_code_snippet: contents
97
+ }.to_json
98
+ response = PWN::AI::Introspection.reflect(request: request)
99
+ if response.is_a?(Hash)
100
+ ai_analysis = response[:choices].last[:text] if response[:choices].last.keys.include?(:text)
101
+ ai_analysis = response[:choices].last[:content] if response[:choices].last.keys.include?(:content)
102
+ end
103
+ end
104
+
89
105
  hash_line[:line_no_and_contents] = line_no_and_contents_arr.push(
90
106
  line_no: line_no,
91
107
  contents: contents,
92
- author: author
108
+ author: author,
109
+ ai_analysis: ai_analysis
93
110
  )
94
111
 
95
112
  current_count += 2
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: false
2
2
 
3
+ require 'json'
3
4
  require 'socket'
4
5
 
5
6
  module PWN
@@ -19,7 +20,8 @@ module PWN
19
20
  dir_path = opts[:dir_path]
20
21
  git_repo_root_uri = opts[:git_repo_root_uri].to_s.scrub
21
22
  result_arr = []
22
- logger_results = ''
23
+ ai_introspection = PWN::Env[:ai][:introspection]
24
+ logger_results = "AI Introspection => #{ai_introspection} => "
23
25
 
24
26
  PWN::Plugins::FileFu.recurse_in_dir(dir_path: dir_path) do |entry|
25
27
  if (File.file?(entry) && File.basename(entry) !~ /^pwn.+(html|json|db)$/ && File.basename(entry) !~ /\.JS-BEAUTIFIED$/) && File.extname(entry) == '.scala' && entry !~ /test/i
@@ -76,10 +78,25 @@ module PWN
76
78
  end
77
79
  author ||= 'N/A'
78
80
 
81
+ ai_analysis = nil
82
+ if ai_introspection
83
+ request = {
84
+ scm_uri: "#{hash_line[:filename][:git_repo_root_uri]}/#{hash_line[:filename][:entry]}",
85
+ line_no: line_no,
86
+ source_code_snippet: contents
87
+ }.to_json
88
+ response = PWN::AI::Introspection.reflect(request: request)
89
+ if response.is_a?(Hash)
90
+ ai_analysis = response[:choices].last[:text] if response[:choices].last.keys.include?(:text)
91
+ ai_analysis = response[:choices].last[:content] if response[:choices].last.keys.include?(:content)
92
+ end
93
+ end
94
+
79
95
  hash_line[:line_no_and_contents] = line_no_and_contents_arr.push(
80
96
  line_no: line_no,
81
97
  contents: contents,
82
- author: author
98
+ author: author,
99
+ ai_analysis: ai_analysis
83
100
  )
84
101
 
85
102
  current_count += 2
data/lib/pwn/sast/csrf.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: false
2
2
 
3
+ require 'json'
3
4
  require 'socket'
4
5
 
5
6
  module PWN
@@ -20,7 +21,8 @@ module PWN
20
21
  dir_path = opts[:dir_path]
21
22
  git_repo_root_uri = opts[:git_repo_root_uri].to_s.scrub
22
23
  result_arr = []
23
- logger_results = ''
24
+ ai_introspection = PWN::Env[:ai][:introspection]
25
+ logger_results = "AI Introspection => #{ai_introspection} => "
24
26
 
25
27
  PWN::Plugins::FileFu.recurse_in_dir(dir_path: dir_path) do |entry|
26
28
  if File.file?(entry) && File.basename(entry) !~ /^pwn.+(html|json|db)$/ && File.basename(entry) !~ /\.JS-BEAUTIFIED$/ && entry !~ /test/i
@@ -75,10 +77,25 @@ module PWN
75
77
  end
76
78
  author ||= 'N/A'
77
79
 
80
+ ai_analysis = nil
81
+ if ai_introspection
82
+ request = {
83
+ scm_uri: "#{hash_line[:filename][:git_repo_root_uri]}/#{hash_line[:filename][:entry]}",
84
+ line_no: line_no,
85
+ source_code_snippet: contents
86
+ }.to_json
87
+ response = PWN::AI::Introspection.reflect(request: request)
88
+ if response.is_a?(Hash)
89
+ ai_analysis = response[:choices].last[:text] if response[:choices].last.keys.include?(:text)
90
+ ai_analysis = response[:choices].last[:content] if response[:choices].last.keys.include?(:content)
91
+ end
92
+ end
93
+
78
94
  hash_line[:line_no_and_contents] = line_no_and_contents_arr.push(
79
95
  line_no: line_no,
80
96
  contents: contents,
81
- author: author
97
+ author: author,
98
+ ai_analysis: ai_analysis
82
99
  )
83
100
 
84
101
  current_count += 2