pwn 0.5.436 → 0.5.437

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 (50) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -3
  3. data/lib/pwn/reports/sast.rb +50 -57
  4. data/lib/pwn/sast/amqp_connect_as_guest.rb +17 -1
  5. data/lib/pwn/sast/apache_file_system_util_api.rb +17 -1
  6. data/lib/pwn/sast/aws.rb +17 -1
  7. data/lib/pwn/sast/banned_function_calls_c.rb +17 -1
  8. data/lib/pwn/sast/base64.rb +17 -1
  9. data/lib/pwn/sast/beef_hook.rb +17 -1
  10. data/lib/pwn/sast/cmd_execution_java.rb +17 -1
  11. data/lib/pwn/sast/cmd_execution_python.rb +17 -1
  12. data/lib/pwn/sast/cmd_execution_ruby.rb +17 -1
  13. data/lib/pwn/sast/cmd_execution_scala.rb +17 -1
  14. data/lib/pwn/sast/csrf.rb +17 -1
  15. data/lib/pwn/sast/deserial_java.rb +17 -1
  16. data/lib/pwn/sast/emoticon.rb +17 -1
  17. data/lib/pwn/sast/eval.rb +17 -1
  18. data/lib/pwn/sast/factory.rb +17 -1
  19. data/lib/pwn/sast/http_authorization_header.rb +17 -1
  20. data/lib/pwn/sast/inner_html.rb +17 -1
  21. data/lib/pwn/sast/keystore.rb +17 -1
  22. data/lib/pwn/sast/local_storage.rb +17 -1
  23. data/lib/pwn/sast/location_hash.rb +17 -1
  24. data/lib/pwn/sast/log4j.rb +17 -1
  25. data/lib/pwn/sast/logger.rb +17 -1
  26. data/lib/pwn/sast/md5.rb +17 -1
  27. data/lib/pwn/sast/outer_html.rb +17 -1
  28. data/lib/pwn/sast/padding_oracle.rb +17 -1
  29. data/lib/pwn/sast/password.rb +17 -1
  30. data/lib/pwn/sast/php_input_mechanisms.rb +17 -1
  31. data/lib/pwn/sast/php_type_juggling.rb +17 -1
  32. data/lib/pwn/sast/pom_version.rb +17 -1
  33. data/lib/pwn/sast/port.rb +17 -1
  34. data/lib/pwn/sast/post_message.rb +17 -1
  35. data/lib/pwn/sast/private_key.rb +17 -1
  36. data/lib/pwn/sast/redirect.rb +17 -1
  37. data/lib/pwn/sast/redos.rb +17 -1
  38. data/lib/pwn/sast/shell.rb +17 -1
  39. data/lib/pwn/sast/signature.rb +17 -1
  40. data/lib/pwn/sast/sql.rb +17 -1
  41. data/lib/pwn/sast/ssl.rb +17 -1
  42. data/lib/pwn/sast/sudo.rb +17 -1
  43. data/lib/pwn/sast/task_tag.rb +17 -1
  44. data/lib/pwn/sast/throw_errors.rb +17 -1
  45. data/lib/pwn/sast/token.rb +17 -1
  46. data/lib/pwn/sast/type_script_type_juggling.rb +17 -1
  47. data/lib/pwn/sast/version.rb +17 -1
  48. data/lib/pwn/sast/window_location_hash.rb +17 -1
  49. data/lib/pwn/version.rb +1 -1
  50. 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: dc4595f20cb20cc81eb1633ea84a91a9d3fd7ab8c7a17b718ec2ba15451412d5
4
+ data.tar.gz: 991eb600f873d5f1ad790ade4791dcacedd3eecab8e6375bb646a3a3c4979afb
5
5
  SHA512:
6
- metadata.gz: 4b4721af1d836061595b1c295100927d2824c19e68ce0f17edec6dd07e707cbf5f01dcc7ca0d697803547b2ecc64a2b527936a7e5f86d7d4ba2f3d44e6ada0e3
7
- data.tar.gz: f0eea79fb719f06556c8b6260181c5dd25067cba7c4e8d800bc3c543b61e05a45907a22add4e73d6b63b3db04771c31e90793344e8d9f3d1da49f0ce2bbd4ac8
6
+ metadata.gz: 289bb8fafb11ccc48cd7335fbbbc451f9629414f2c7d4f47913d2568649ae63b57d36cf3e5d8711bb38dd8ce59741f629d27a264aa4879daca55d851a635e430
7
+ data.tar.gz: fc6256cc8b76c11f1286531e97c762572bda96fe337b73a905e30941fedc7978ce69886cf1f77a8895ee2284cdf624fe732df1407f36027f70ffaceb5ad1eee2
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.437]: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.437]: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.437]: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:
@@ -25,62 +25,55 @@ module PWN
25
25
  }
26
26
  report_name = opts[:report_name] ||= File.basename(Dir.pwd)
27
27
 
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
28
  # 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
29
+ # total_entries = results_hash[:data].sum { |entry| entry[:line_no_and_contents].size }
30
+ # puts "Total entries to analyze: #{total_entries}" if engine
31
+
32
+ # percent_complete = 0.0
33
+ # entry_count = 0
34
+ # spin = TTY::Spinner.new(
35
+ # '[:spinner] Report Generation Progress: :percent_complete :entry_count of :total_entries',
36
+ # format: :dots,
37
+ # hide_cursor: true
38
+ # )
39
+ # spin.auto_spin
40
+
41
+ # ai_instrospection = PWN::Env[:ai][:introspection]
42
+ # puts "Analyzing source code using AI engine: #{engine}\nModel: #{model}\nSystem Role Content: #{system_role_content}\nTemperature: #{temp}" if ai_instrospection
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
+ # response = nil
54
+ # if ai_instrospection
55
+ # request = {
56
+ # scm_uri: "#{git_repo_root_uri}/#{filename}",
57
+ # line: line_no,
58
+ # source_code_snippet: source_code_snippet
59
+ # }.to_json
60
+ # response = PWN::AI::Introspection.reflect(request: request)
61
+ # end
62
+ # ai_analysis = nil
63
+ # if response.is_a?(Hash)
64
+ # ai_analysis = response[:choices].last[:text] if response[:choices].last.keys.include?(:text)
65
+ # ai_analysis = response[:choices].last[:content] if response[:choices].last.keys.include?(:content)
66
+ # puts "AI Analysis Progress: #{percent_complete}% Line: #{line_no} | Author: #{author} | AI Analysis: #{ai_analysis}\n\n\n" if ai_analysis
67
+ # end
68
+ # src_detail[:ai_analysis] = ai_analysis.to_s.scrub.chomp.strip
69
+ # spin.update(
70
+ # percent_complete: "#{percent_complete}%",
71
+ # entry_count: entry_count,
72
+ # total_entries: total_entries
73
+ # )
74
+ # end
75
+ # end
76
+
84
77
  # JSON object Completion
85
78
  # File.open("#{dir_path}/pwn_scan_git_source.json", 'w') do |f|
86
79
  # f.print(results_hash.to_json)
@@ -467,8 +460,8 @@ module PWN
467
460
  end
468
461
  rescue StandardError => e
469
462
  raise e
470
- ensure
471
- spin.stop unless spin.nil?
463
+ # ensure
464
+ # spin.stop unless spin.nil?
472
465
  end
473
466
 
474
467
  # Author(s):: 0day Inc. <support@0dayinc.com>
@@ -75,10 +75,26 @@ module PWN
75
75
  end
76
76
  author ||= 'N/A'
77
77
 
78
+ ai_instrospection = PWN::Env[:ai][:introspection]
79
+ ai_analysis = nil
80
+ if ai_instrospection
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
+
78
93
  hash_line[:line_no_and_contents] = line_no_and_contents_arr.push(
79
94
  line_no: line_no,
80
95
  contents: contents,
81
- author: author
96
+ author: author,
97
+ ai_analysis: ai_analysis
82
98
  )
83
99
  current_count += 2
84
100
  end
@@ -75,10 +75,26 @@ module PWN
75
75
  end
76
76
  author ||= 'N/A'
77
77
 
78
+ ai_instrospection = PWN::Env[:ai][:introspection]
79
+ ai_analysis = nil
80
+ if ai_instrospection
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
+
78
93
  hash_line[:line_no_and_contents] = line_no_and_contents_arr.push(
79
94
  line_no: line_no,
80
95
  contents: contents,
81
- author: author
96
+ author: author,
97
+ ai_analysis: ai_analysis
82
98
  )
83
99
 
84
100
  current_count += 2
data/lib/pwn/sast/aws.rb CHANGED
@@ -76,10 +76,26 @@ module PWN
76
76
  end
77
77
  author ||= 'N/A'
78
78
 
79
+ ai_instrospection = PWN::Env[:ai][:introspection]
80
+ ai_analysis = nil
81
+ if ai_instrospection
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
+
79
94
  hash_line[:line_no_and_contents] = line_no_and_contents_arr.push(
80
95
  line_no: line_no,
81
96
  contents: contents,
82
- author: author
97
+ author: author,
98
+ ai_analysis: ai_analysis
83
99
  )
84
100
 
85
101
  current_count += 2
@@ -203,10 +203,26 @@ module PWN
203
203
  end
204
204
  author ||= 'N/A'
205
205
 
206
+ ai_instrospection = PWN::Env[:ai][:introspection]
207
+ ai_analysis = nil
208
+ if ai_instrospection
209
+ request = {
210
+ scm_uri: "#{hash_line[:filename][:git_repo_root_uri]}/#{hash_line[:filename][:entry]}",
211
+ line_no: line_no,
212
+ source_code_snippet: contents
213
+ }.to_json
214
+ response = PWN::AI::Introspection.reflect(request: request)
215
+ if response.is_a?(Hash)
216
+ ai_analysis = response[:choices].last[:text] if response[:choices].last.keys.include?(:text)
217
+ ai_analysis = response[:choices].last[:content] if response[:choices].last.keys.include?(:content)
218
+ end
219
+ end
220
+
206
221
  hash_line[:line_no_and_contents] = line_no_and_contents_arr.push(
207
222
  line_no: line_no,
208
223
  contents: contents,
209
- author: author
224
+ author: author,
225
+ ai_analysis: ai_analysis
210
226
  )
211
227
 
212
228
  current_count += 2
@@ -74,10 +74,26 @@ module PWN
74
74
  end
75
75
  author ||= 'N/A'
76
76
 
77
+ ai_instrospection = PWN::Env[:ai][:introspection]
78
+ ai_analysis = nil
79
+ if ai_instrospection
80
+ request = {
81
+ scm_uri: "#{hash_line[:filename][:git_repo_root_uri]}/#{hash_line[:filename][:entry]}",
82
+ line_no: line_no,
83
+ source_code_snippet: contents
84
+ }.to_json
85
+ response = PWN::AI::Introspection.reflect(request: request)
86
+ if response.is_a?(Hash)
87
+ ai_analysis = response[:choices].last[:text] if response[:choices].last.keys.include?(:text)
88
+ ai_analysis = response[:choices].last[:content] if response[:choices].last.keys.include?(:content)
89
+ end
90
+ end
91
+
77
92
  hash_line[:line_no_and_contents] = line_no_and_contents_arr.push(
78
93
  line_no: line_no,
79
94
  contents: contents,
80
- author: author
95
+ author: author,
96
+ ai_analysis: ai_analysis
81
97
  )
82
98
 
83
99
  current_count += 2
@@ -74,10 +74,26 @@ module PWN
74
74
  end
75
75
  author ||= 'N/A'
76
76
 
77
+ ai_instrospection = PWN::Env[:ai][:introspection]
78
+ ai_analysis = nil
79
+ if ai_instrospection
80
+ request = {
81
+ scm_uri: "#{hash_line[:filename][:git_repo_root_uri]}/#{hash_line[:filename][:entry]}",
82
+ line_no: line_no,
83
+ source_code_snippet: contents
84
+ }.to_json
85
+ response = PWN::AI::Introspection.reflect(request: request)
86
+ if response.is_a?(Hash)
87
+ ai_analysis = response[:choices].last[:text] if response[:choices].last.keys.include?(:text)
88
+ ai_analysis = response[:choices].last[:content] if response[:choices].last.keys.include?(:content)
89
+ end
90
+ end
91
+
77
92
  hash_line[:line_no_and_contents] = line_no_and_contents_arr.push(
78
93
  line_no: line_no,
79
94
  contents: contents,
80
- author: author
95
+ author: author,
96
+ ai_analysis: ai_analysis
81
97
  )
82
98
 
83
99
  current_count += 2
@@ -76,10 +76,26 @@ module PWN
76
76
  end
77
77
  author ||= 'N/A'
78
78
 
79
+ ai_instrospection = PWN::Env[:ai][:introspection]
80
+ ai_analysis = nil
81
+ if ai_instrospection
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
+
79
94
  hash_line[:line_no_and_contents] = line_no_and_contents_arr.push(
80
95
  line_no: line_no,
81
96
  contents: contents,
82
- author: author
97
+ author: author,
98
+ ai_analysis: ai_analysis
83
99
  )
84
100
 
85
101
  current_count += 2
@@ -78,10 +78,26 @@ module PWN
78
78
  end
79
79
  author ||= 'N/A'
80
80
 
81
+ ai_instrospection = PWN::Env[:ai][:introspection]
82
+ ai_analysis = nil
83
+ if ai_instrospection
84
+ request = {
85
+ scm_uri: "#{hash_line[:filename][:git_repo_root_uri]}/#{hash_line[:filename][:entry]}",
86
+ line_no: line_no,
87
+ source_code_snippet: contents
88
+ }.to_json
89
+ response = PWN::AI::Introspection.reflect(request: request)
90
+ if response.is_a?(Hash)
91
+ ai_analysis = response[:choices].last[:text] if response[:choices].last.keys.include?(:text)
92
+ ai_analysis = response[:choices].last[:content] if response[:choices].last.keys.include?(:content)
93
+ end
94
+ end
95
+
81
96
  hash_line[:line_no_and_contents] = line_no_and_contents_arr.push(
82
97
  line_no: line_no,
83
98
  contents: contents,
84
- author: author
99
+ author: author,
100
+ ai_analysis: ai_analysis
85
101
  )
86
102
 
87
103
  current_count += 2
@@ -86,10 +86,26 @@ module PWN
86
86
  end
87
87
  author ||= 'N/A'
88
88
 
89
+ ai_instrospection = PWN::Env[:ai][:introspection]
90
+ ai_analysis = nil
91
+ if ai_instrospection
92
+ request = {
93
+ scm_uri: "#{hash_line[:filename][:git_repo_root_uri]}/#{hash_line[:filename][:entry]}",
94
+ line_no: line_no,
95
+ source_code_snippet: contents
96
+ }.to_json
97
+ response = PWN::AI::Introspection.reflect(request: request)
98
+ if response.is_a?(Hash)
99
+ ai_analysis = response[:choices].last[:text] if response[:choices].last.keys.include?(:text)
100
+ ai_analysis = response[:choices].last[:content] if response[:choices].last.keys.include?(:content)
101
+ end
102
+ end
103
+
89
104
  hash_line[:line_no_and_contents] = line_no_and_contents_arr.push(
90
105
  line_no: line_no,
91
106
  contents: contents,
92
- author: author
107
+ author: author,
108
+ ai_analysis: ai_analysis
93
109
  )
94
110
 
95
111
  current_count += 2
@@ -76,10 +76,26 @@ module PWN
76
76
  end
77
77
  author ||= 'N/A'
78
78
 
79
+ ai_instrospection = PWN::Env[:ai][:introspection]
80
+ ai_analysis = nil
81
+ if ai_instrospection
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
+
79
94
  hash_line[:line_no_and_contents] = line_no_and_contents_arr.push(
80
95
  line_no: line_no,
81
96
  contents: contents,
82
- author: author
97
+ author: author,
98
+ ai_analysis: ai_analysis
83
99
  )
84
100
 
85
101
  current_count += 2
data/lib/pwn/sast/csrf.rb CHANGED
@@ -75,10 +75,26 @@ module PWN
75
75
  end
76
76
  author ||= 'N/A'
77
77
 
78
+ ai_instrospection = PWN::Env[:ai][:introspection]
79
+ ai_analysis = nil
80
+ if ai_instrospection
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
+
78
93
  hash_line[:line_no_and_contents] = line_no_and_contents_arr.push(
79
94
  line_no: line_no,
80
95
  contents: contents,
81
- author: author
96
+ author: author,
97
+ ai_analysis: ai_analysis
82
98
  )
83
99
 
84
100
  current_count += 2
@@ -83,10 +83,26 @@ module PWN
83
83
  end
84
84
  author ||= 'N/A'
85
85
 
86
+ ai_instrospection = PWN::Env[:ai][:introspection]
87
+ ai_analysis = nil
88
+ if ai_instrospection
89
+ request = {
90
+ scm_uri: "#{hash_line[:filename][:git_repo_root_uri]}/#{hash_line[:filename][:entry]}",
91
+ line_no: line_no,
92
+ source_code_snippet: contents
93
+ }.to_json
94
+ response = PWN::AI::Introspection.reflect(request: request)
95
+ if response.is_a?(Hash)
96
+ ai_analysis = response[:choices].last[:text] if response[:choices].last.keys.include?(:text)
97
+ ai_analysis = response[:choices].last[:content] if response[:choices].last.keys.include?(:content)
98
+ end
99
+ end
100
+
86
101
  hash_line[:line_no_and_contents] = line_no_and_contents_arr.push(
87
102
  line_no: line_no,
88
103
  contents: contents,
89
- author: author
104
+ author: author,
105
+ ai_analysis: ai_analysis
90
106
  )
91
107
 
92
108
  current_count += 2
@@ -81,10 +81,26 @@ module PWN
81
81
  end
82
82
  author ||= 'N/A'
83
83
 
84
+ ai_instrospection = PWN::Env[:ai][:introspection]
85
+ ai_analysis = nil
86
+ if ai_instrospection
87
+ request = {
88
+ scm_uri: "#{hash_line[:filename][:git_repo_root_uri]}/#{hash_line[:filename][:entry]}",
89
+ line_no: line_no,
90
+ source_code_snippet: contents
91
+ }.to_json
92
+ response = PWN::AI::Introspection.reflect(request: request)
93
+ if response.is_a?(Hash)
94
+ ai_analysis = response[:choices].last[:text] if response[:choices].last.keys.include?(:text)
95
+ ai_analysis = response[:choices].last[:content] if response[:choices].last.keys.include?(:content)
96
+ end
97
+ end
98
+
84
99
  hash_line[:line_no_and_contents] = line_no_and_contents_arr.push(
85
100
  line_no: line_no,
86
101
  contents: contents,
87
- author: author
102
+ author: author,
103
+ ai_analysis: ai_analysis
88
104
  )
89
105
 
90
106
  current_count += 2
data/lib/pwn/sast/eval.rb CHANGED
@@ -75,10 +75,26 @@ module PWN
75
75
  end
76
76
  author ||= 'N/A'
77
77
 
78
+ ai_instrospection = PWN::Env[:ai][:introspection]
79
+ ai_analysis = nil
80
+ if ai_instrospection
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
+
78
93
  hash_line[:line_no_and_contents] = line_no_and_contents_arr.push(
79
94
  line_no: line_no,
80
95
  contents: contents,
81
- author: author
96
+ author: author,
97
+ ai_analysis: ai_analysis
82
98
  )
83
99
 
84
100
  current_count += 2
@@ -78,10 +78,26 @@ module PWN
78
78
  end
79
79
  author ||= 'N/A'
80
80
 
81
+ ai_instrospection = PWN::Env[:ai][:introspection]
82
+ ai_analysis = nil
83
+ if ai_instrospection
84
+ request = {
85
+ scm_uri: "#{hash_line[:filename][:git_repo_root_uri]}/#{hash_line[:filename][:entry]}",
86
+ line_no: line_no,
87
+ source_code_snippet: contents
88
+ }.to_json
89
+ response = PWN::AI::Introspection.reflect(request: request)
90
+ if response.is_a?(Hash)
91
+ ai_analysis = response[:choices].last[:text] if response[:choices].last.keys.include?(:text)
92
+ ai_analysis = response[:choices].last[:content] if response[:choices].last.keys.include?(:content)
93
+ end
94
+ end
95
+
81
96
  hash_line[:line_no_and_contents] = line_no_and_contents_arr.push(
82
97
  line_no: line_no,
83
98
  contents: contents,
84
- author: author
99
+ author: author,
100
+ ai_analysis: ai_analysis
85
101
  )
86
102
 
87
103
  current_count += 2
@@ -83,10 +83,26 @@ module PWN
83
83
  end
84
84
  author ||= 'N/A'
85
85
 
86
+ ai_instrospection = PWN::Env[:ai][:introspection]
87
+ ai_analysis = nil
88
+ if ai_instrospection
89
+ request = {
90
+ scm_uri: "#{hash_line[:filename][:git_repo_root_uri]}/#{hash_line[:filename][:entry]}",
91
+ line_no: line_no,
92
+ source_code_snippet: contents
93
+ }.to_json
94
+ response = PWN::AI::Introspection.reflect(request: request)
95
+ if response.is_a?(Hash)
96
+ ai_analysis = response[:choices].last[:text] if response[:choices].last.keys.include?(:text)
97
+ ai_analysis = response[:choices].last[:content] if response[:choices].last.keys.include?(:content)
98
+ end
99
+ end
100
+
86
101
  hash_line[:line_no_and_contents] = line_no_and_contents_arr.push(
87
102
  line_no: line_no,
88
103
  contents: contents,
89
- author: author
104
+ author: author,
105
+ ai_analysis: ai_analysis
90
106
  )
91
107
 
92
108
  current_count += 2
@@ -75,10 +75,26 @@ module PWN
75
75
  end
76
76
  author ||= 'N/A'
77
77
 
78
+ ai_instrospection = PWN::Env[:ai][:introspection]
79
+ ai_analysis = nil
80
+ if ai_instrospection
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
+
78
93
  hash_line[:line_no_and_contents] = line_no_and_contents_arr.push(
79
94
  line_no: line_no,
80
95
  contents: contents,
81
- author: author
96
+ author: author,
97
+ ai_analysis: ai_analysis
82
98
  )
83
99
 
84
100
  current_count += 2