pwn 0.5.301 → 0.5.303

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ccbfcfff8dc15fb9976418982c7d3f0c302fc210c57019587ad20b7c5f5dfe54
4
- data.tar.gz: 602f258ba2304490e060fb36927164278680da8dfcd381ade3bb121277349b1a
3
+ metadata.gz: c05b6705a2d4cb4d1e2fbccc6eff8e9752df2660610d577bc62397d116e4164a
4
+ data.tar.gz: 8d9f9ec925222a6c8650ebb9e637a71264f258581e138ee650199699fbd81751
5
5
  SHA512:
6
- metadata.gz: 0bb149c10dd9dd0d27051d05aef4493f66413f2e0a0641112158d4a4808f24a930224dd0fc42598a8cbaa846f3d0064351a2a5791632db1d5413d9afcb37659c
7
- data.tar.gz: c2f60d489791334c2914a7e4ae122b623ef2e96de2bc9e9db7d025b381f612f3f8e5f8ecbf8f70835a12d19236f28a78c689df90cfdd03da2bbf924662276cc9
6
+ metadata.gz: 5f0aa077f65377bc75d46a4fc5a60eb200b142075f0d4d1c3eb78caa05d54c8abdf50f1f64855ff86ef993c178e415f8865fbdb2a26086a2a5dff73ea67248dc
7
+ data.tar.gz: c02c7cdc07bda2ecd0790af222f6e5eccff0219c87e61edd66d596c53817f23a6e07b3dae2e959fe0028b866a8f10ae4a478b825dbb98899ff0e9051541df5d3
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.301]:001 >>> PWN.help
40
+ pwn[v0.5.303]: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.301]:001 >>> PWN.help
55
+ pwn[v0.5.303]: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.301]:001 >>> PWN.help
65
+ pwn[v0.5.303]: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:
@@ -43,7 +43,7 @@ if (( $# == 3 )); then
43
43
  latest_gem=$(ls pkg/*.gem)
44
44
  if [[ $latest_gem != "" ]]; then
45
45
  echo "Pushing ${latest_gem} to RubyGems.org..."
46
- rvmsudo gem push $latest_gem --debug
46
+ rvmsudo gem push $latest_gem
47
47
  fi
48
48
 
49
49
  if [[ $tag_this_version_bool == 'true' ]]; then
@@ -82,10 +82,15 @@ module PWN
82
82
  raise @@logger.error("Unsupported HTTP Method #{http_method} for #{self} Plugin")
83
83
  end
84
84
 
85
- jira_response = response if response.is_a?(RestClient::Response) && response.code == 204
86
- jira_response = JSON.parse(response, symbolize_names: true) if response.is_a?(RestClient::Response) && response.code != 204
85
+ case response.code
86
+ when 201, 204
87
+ response = { http_response_code: response.code }
88
+ else
89
+ response = JSON.parse(response, symbolize_names: true) if response.is_a?(RestClient::Response)
90
+ response[:http_response_code] = response.code if response.is_a?(RestClient::Response)
91
+ end
87
92
 
88
- jira_response
93
+ response
89
94
  rescue RestClient::ExceptionWithResponse => e
90
95
  if e.response
91
96
  puts "HTTP BASE URL: #{base_api_uri}"
@@ -219,7 +224,8 @@ module PWN
219
224
  # description: 'optional - description of the issue',
220
225
  # epic_name: 'optional - name of the epic',
221
226
  # additional_fields: 'optional - additional fields to set in the issue (e.g. labels, components, custom fields, etc.)'
222
- # attachment: 'optional - attachment path to upload to the issue (e.g. "/path/to/file1.txt")'
227
+ # attachments: 'optional - array of attachment paths to upload to the issue (e.g. ["/tmp/file1.txt", "/tmp/file2.txt"])',
228
+ # comment: 'optional - comment to add to the issue (e.g. "This is a comment")'
223
229
  # )
224
230
 
225
231
  public_class_method def self.create_issue(opts = {})
@@ -243,7 +249,10 @@ module PWN
243
249
  additional_fields = opts[:additional_fields] ||= { fields: {} }
244
250
  raise 'ERROR: additional_fields Hash must contain a :fields key that is also a Hash.' unless additional_fields.is_a?(Hash) && additional_fields.key?(:fields) && additional_fields[:fields].is_a?(Hash)
245
251
 
246
- attachment = opts[:attachment]
252
+ attachments = opts[:attachments] ||= []
253
+ raise 'ERROR: attachments must be an Array.' unless attachments.is_a?(Array)
254
+
255
+ comment = opts[:comment]
247
256
 
248
257
  all_fields = get_all_fields(base_api_uri: base_api_uri, token: token)
249
258
  epic_name_field_key = all_fields.find { |field| field[:name] == 'Epic Name' }[:id]
@@ -273,27 +282,42 @@ module PWN
273
282
  rest_call: 'issue',
274
283
  http_body: http_body
275
284
  )
285
+ issue = issue_resp[:key]
286
+
287
+ if attachments.any?
288
+ attachments.each do |attachment|
289
+ raise "ERROR: #{attachment} not found." unless File.exist?(attachment)
290
+
291
+ http_body = {
292
+ multipart: true,
293
+ file: File.new(attachment, 'rb')
294
+ }
295
+
296
+ rest_call(
297
+ http_method: :post,
298
+ base_api_uri: base_api_uri,
299
+ token: token,
300
+ rest_call: "issue/#{issue}/attachments",
301
+ http_body: http_body
302
+ )
303
+ end
304
+ end
276
305
 
277
- if attachment
278
- raise "ERROR: #{attachment} not found." unless File.exist?(attachment)
279
-
280
- issue = issue_resp[:key]
281
-
282
- http_body = {
283
- multipart: true,
284
- file: File.new(attachment, 'rb')
285
- }
286
-
287
- rest_call(
288
- http_method: :post,
306
+ if comment
307
+ issue_comment(
289
308
  base_api_uri: base_api_uri,
290
309
  token: token,
291
- rest_call: "issue/#{issue}/attachments",
292
- http_body: http_body
310
+ issue: issue,
311
+ comment_action: :add,
312
+ comment: comment
293
313
  )
294
314
  end
295
315
 
296
- issue_resp
316
+ get_issue(
317
+ base_api_uri: base_api_uri,
318
+ token: token,
319
+ issue: issue
320
+ )
297
321
  rescue StandardError => e
298
322
  raise e
299
323
  end
@@ -303,7 +327,7 @@ module PWN
303
327
  # base_api_uri: 'required - base URI for Jira (e.g. https:/jira.corp.com/rest/api/latest)',
304
328
  # token: 'required - personal access token',
305
329
  # fields: 'required - fields to update in the issue (e.g. summary, description, labels, components, custom fields, etc.)',
306
- # attachment: 'optional - attachment path to upload to the issue (e.g. "/path/to/file1.txt")'
330
+ # attachments: 'optional - array of attachment paths to upload to the issue (e.g. ["/tmp/file1.txt", "/tmp/file2.txt"])',
307
331
  # )
308
332
 
309
333
  public_class_method def self.update_issue(opts = {})
@@ -319,11 +343,12 @@ module PWN
319
343
  fields = opts[:fields] ||= { fields: {} }
320
344
  raise 'ERROR: fields Hash must contain a :fields key that is also a Hash.' unless fields.is_a?(Hash) && fields.key?(:fields) && fields[:fields].is_a?(Hash)
321
345
 
322
- attachment = opts[:attachment]
346
+ attachments = opts[:attachments] ||= []
347
+ raise 'ERROR: attachments must be an Array.' unless attachments.is_a?(Array)
323
348
 
324
349
  http_body = fields
325
350
 
326
- issue_resp = rest_call(
351
+ rest_call(
327
352
  http_method: :put,
328
353
  base_api_uri: base_api_uri,
329
354
  token: token,
@@ -331,24 +356,95 @@ module PWN
331
356
  http_body: http_body
332
357
  )
333
358
 
334
- if attachment
335
- raise "ERROR: #{attachment} not found." unless File.exist?(attachment)
359
+ if attachments.any?
360
+ attachments.each do |attachment|
361
+ raise "ERROR: #{attachment} not found." unless File.exist?(attachment)
362
+
363
+ http_body = {
364
+ multipart: true,
365
+ file: File.new(attachment, 'rb')
366
+ }
367
+
368
+ rest_call(
369
+ http_method: :post,
370
+ base_api_uri: base_api_uri,
371
+ token: token,
372
+ rest_call: "issue/#{issue}/attachments",
373
+ http_body: http_body
374
+ )
375
+ end
376
+ end
336
377
 
337
- http_body = {
338
- multipart: true,
339
- file: File.new(attachment, 'rb')
340
- }
378
+ get_issue(
379
+ base_api_uri: base_api_uri,
380
+ token: token,
381
+ issue: issue
382
+ )
383
+ rescue StandardError => e
384
+ raise e
385
+ end
341
386
 
342
- rest_call(
343
- http_method: :post,
344
- base_api_uri: base_api_uri,
345
- token: token,
346
- rest_call: "issue/#{issue}/attachments",
347
- http_body: http_body
348
- )
387
+ # Supported Method Parameters::
388
+ # issue_resp = PWN::Plugins::JiraServer.issue_comment(
389
+ # base_api_uri: 'required - base URI for Jira (e.g. https:/jira.corp.com/rest/api/latest)',
390
+ # token: 'required - personal access token',
391
+ # issue: 'required - issue to delete (e.g. Bug, Issue, Story, or Epic ID)',
392
+ # comment_action: 'required - action to perform on the issue comment (e.g. :delete, :add, :update - Defaults to :add)',
393
+ # comment_id: 'optional - comment ID to delete or update (e.g. 10000)',
394
+ # author: 'optional - author of the comment (e.g. "jane.doe")',
395
+ # comment: 'optional - comment to add or update in the issue (e.g. "This is a comment")'
396
+ # )
397
+
398
+ public_class_method def self.issue_comment(opts = {})
399
+ base_api_uri = opts[:base_api_uri]
400
+
401
+ token = opts[:token]
402
+ token ||= PWN::Plugins::AuthenticationHelper.mask_password(
403
+ prompt: 'Personal Access Token'
404
+ )
405
+
406
+ issue = opts[:issue]
407
+ raise 'ERROR: issue cannot be nil.' if issue.nil?
408
+
409
+ comment_action = opts[:comment_action] ||= :add
410
+ raise 'ERROR: comment_action must be one of :delete, :add, or :update.' unless %i[delete add update].include?(comment_action)
411
+
412
+ comment_id = opts[:comment_id]
413
+ raise 'ERROR: comment_id cannot be nil when comment_action is :delete or :update.' unless %i[delete update].include?(comment_action) || comment_id.nil?
414
+
415
+ author = opts[:author]
416
+ comment = opts[:comment].to_s.scrub
417
+
418
+ case comment_action
419
+ when :add
420
+ http_method = :post
421
+ rest_call = "issue/#{issue}/comment"
422
+ http_body = { body: comment }
423
+ http_body[:author] = author if author
424
+ when :delete
425
+ http_method = :delete
426
+ rest_call = "issue/#{issue}/comment/#{comment_id}"
427
+ http_body = nil
428
+ when :update
429
+ http_method = :put
430
+ rest_call = "issue/#{issue}/comment/#{comment_id}"
431
+ http_body = { body: comment }
432
+ http_body[:author] = author if author
349
433
  end
350
434
 
351
- issue_resp
435
+ rest_call(
436
+ http_method: http_method,
437
+ base_api_uri: base_api_uri,
438
+ token: token,
439
+ rest_call: rest_call,
440
+ http_body: http_body
441
+ )
442
+
443
+ get_issue(
444
+ base_api_uri: base_api_uri,
445
+ token: token,
446
+ issue: issue
447
+ )
352
448
  rescue StandardError => e
353
449
  raise e
354
450
  end
@@ -369,7 +465,6 @@ module PWN
369
465
  )
370
466
 
371
467
  issue = opts[:issue]
372
-
373
468
  raise 'ERROR: issue cannot be nil.' if issue.nil?
374
469
 
375
470
  rest_call(
@@ -382,6 +477,34 @@ module PWN
382
477
  raise e
383
478
  end
384
479
 
480
+ # Supported Method Parameters::
481
+ # issue_resp = PWN::Plugins::JiraServer.delete_attachment(
482
+ # base_api_uri: 'required - base URI for Jira (e.g. https:/jira.corp.com/rest/api/latest)',
483
+ # token: 'required - personal access token',
484
+ # id: 'required - attachment ID to delete (e.g. 10000) found in #get_issue method'
485
+ # )
486
+
487
+ public_class_method def self.delete_attachment(opts = {})
488
+ base_api_uri = opts[:base_api_uri]
489
+
490
+ token = opts[:token]
491
+ token ||= PWN::Plugins::AuthenticationHelper.mask_password(
492
+ prompt: 'Personal Access Token'
493
+ )
494
+
495
+ id = opts[:id]
496
+ raise 'ERROR: attachment_id cannot be nil.' if id.nil?
497
+
498
+ rest_call(
499
+ http_method: :delete,
500
+ base_api_uri: base_api_uri,
501
+ token: token,
502
+ rest_call: "attachment/#{id}"
503
+ )
504
+ rescue StandardError => e
505
+ raise e
506
+ end
507
+
385
508
  # Author(s):: 0day Inc. <support@0dayinc.com>
386
509
 
387
510
  public_class_method def self.authors
@@ -422,7 +545,8 @@ module PWN
422
545
  description: 'optional - description of the issue',
423
546
  epic_name: 'optional - name of the epic',
424
547
  additional_fields: 'optional - additional fields to set in the issue (e.g. labels, components, custom fields, etc.)',
425
- attachment: 'optional - attachment path to upload to the issue (e.g. \"/path/to/file1.txt\")'
548
+ attachments: 'optional - array of attachment paths to upload to the issue (e.g. [\"/tmp/file1.txt\", \"/tmp/file2.txt\"])',
549
+ comment: 'optional - comment to add to the issue (e.g. \"This is a comment\")'
426
550
  )
427
551
 
428
552
  issue_resp = #{self}.update_issue(
@@ -430,7 +554,17 @@ module PWN
430
554
  token: 'required - personal access token',
431
555
  issue: 'required - issue to update (e.g. Bug, Issue, Story, or Epic ID)',
432
556
  fields: 'required - fields to update in the issue (e.g. summary, description, labels, components, custom fields, etc.)',
433
- attachment: 'optional - attachment path to upload to the issue (e.g. \"/path/to/file1.txt\")'
557
+ attachments: 'optional - array of attachment paths to upload to the issue (e.g. [\"/tmp/file1.txt\", \"/tmp/file2.txt\"])'
558
+ )
559
+
560
+ issue_resp = #{self}.issue_comment(
561
+ base_api_uri: 'required - base URI for Jira (e.g. https:/jira.corp.com/rest/api/latest)',
562
+ token: 'required - personal access token',
563
+ issue: 'required - issue to comment on (e.g. Bug, Issue, Story, or Epic ID)',
564
+ comment_action: 'required - action to perform on the issue comment (e.g. :delete, :add, :update - Defaults to :add)',
565
+ comment_id: 'optional - comment ID to delete or update (e.g. 10000)',
566
+ author: 'optional - author of the comment (e.g. \"jane.doe\")',
567
+ comment: 'optional - comment to add or update in the issue (e.g. \"This is a comment\")'
434
568
  )
435
569
 
436
570
  issue_resp = #{self}.delete_issue(
@@ -439,6 +573,12 @@ module PWN
439
573
  issue: 'required - issue to delete (e.g. Bug, Issue, Story, or Epic ID)'
440
574
  )
441
575
 
576
+ issue_resp = #{self}.delete_attachment(
577
+ base_api_uri: 'required - base URI for Jira (e.g. https:/jira.corp.com/rest/api/latest)',
578
+ token: 'required - personal access token',
579
+ id: 'required - attachment ID to delete (e.g. 10000) found in #get_issue method'
580
+ )
581
+
442
582
  **********************************************************************
443
583
  * For more information on the Jira Server REST API, see:
444
584
  * https://developer.atlassian.com/server/jira/platform/rest-apis/
data/lib/pwn/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PWN
4
- VERSION = '0.5.301'
4
+ VERSION = '0.5.303'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pwn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.301
4
+ version: 0.5.303
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.