Skip to content

Commit fc201e5

Browse files
authored
Merge pull request #730 from ninp0/master
PWN::Plugins::JiraServer module - add #update_issue && #delete_issue …
2 parents ecb8846 + eb14b6c commit fc201e5

File tree

3 files changed

+78
-9
lines changed

3 files changed

+78
-9
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ $ cd /opt/pwn
3737
$ ./install.sh
3838
$ ./install.sh ruby-gem
3939
$ pwn
40-
pwn[v0.5.294]:001 >>> PWN.help
40+
pwn[v0.5.295]:001 >>> PWN.help
4141
```
4242

4343
[![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
5252
$ gem uninstall --all --executables pwn
5353
$ gem install --verbose pwn
5454
$ pwn
55-
pwn[v0.5.294]:001 >>> PWN.help
55+
pwn[v0.5.295]:001 >>> PWN.help
5656
```
5757

5858
If you're using a multi-user install of RVM do:
@@ -62,7 +62,7 @@ $ rvm use ruby-3.4.4@pwn
6262
$ rvmsudo gem uninstall --all --executables pwn
6363
$ rvmsudo gem install --verbose pwn
6464
$ pwn
65-
pwn[v0.5.294]:001 >>> PWN.help
65+
pwn[v0.5.295]:001 >>> PWN.help
6666
```
6767

6868
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:

lib/pwn/plugins/jira_server.rb

Lines changed: 74 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ module JiraServer
4343
spinner.auto_spin
4444

4545
case http_method
46-
when :get
46+
when :delete, :get
4747
response = rest_client.execute(
48-
method: :get,
48+
method: http_method,
4949
url: "#{base_api_uri}/#{rest_call}",
5050
headers: {
5151
content_type: 'application/json; charset=UTF-8',
@@ -55,9 +55,9 @@ module JiraServer
5555
verify_ssl: false
5656
)
5757

58-
when :post
58+
when :post, :put
5959
response = rest_client.execute(
60-
method: :post,
60+
method: http_method,
6161
url: "#{base_api_uri}/#{rest_call}",
6262
headers: {
6363
content_type: 'application/json; charset=UTF-8',
@@ -171,7 +171,7 @@ module JiraServer
171171
description = opts[:description].to_s.scrub
172172

173173
additional_fields = opts[:additional_fields] ||= { fields: {} }
174-
raise 'ERROR: additional_fields Hash must contain a :fields key.' unless additional_fields.is_a?(Hash) && additional_fields.key?(:fields)
174+
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)
175175

176176
all_fields = get_all_fields(base_api_uri: base_api_uri, token: token)
177177
epic_name_field_key = all_fields.find { |field| field[:name] == 'Epic Name' }[:id]
@@ -205,6 +205,68 @@ module JiraServer
205205
raise e
206206
end
207207

208+
# Supported Method Parameters::
209+
# issue_resp = PWN::Plugins::JiraServer.update_issue(
210+
# base_api_uri: 'required - base URI for Jira (e.g. https:/jira.corp.com/rest/api/latest)',
211+
# token: 'required - bearer token',
212+
# fields: 'required - fields to update in the issue (e.g. summary, description, labels, components, custom fields, etc.)'
213+
# )
214+
215+
public_class_method def self.update_issue(opts = {})
216+
base_api_uri = opts[:base_api_uri]
217+
218+
token = opts[:token]
219+
token ||= PWN::Plugins::AuthenticationHelper.mask_password(
220+
prompt: 'Personal Access Token'
221+
)
222+
issue = opts[:issue]
223+
raise 'ERROR: project_key cannot be nil.' if issue.nil?
224+
225+
fields = opts[:fields] ||= { fields: {} }
226+
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)
227+
228+
http_body = fields
229+
230+
rest_call(
231+
http_method: :put,
232+
base_api_uri: base_api_uri,
233+
token: token,
234+
rest_call: "issue/#{issue}",
235+
http_body: http_body
236+
)
237+
rescue StandardError => e
238+
raise e
239+
end
240+
241+
# Supported Method Parameters::
242+
# issue_resp = PWN::Plugins::JiraServer.delete_issue(
243+
# base_api_uri: 'required - base URI for Jira (e.g. https:/jira.corp.com/rest/api/latest)',
244+
# token: 'required - bearer token',
245+
# issue: 'required - issue to delete (e.g. Bug, Issue, Story, or Epic ID)'
246+
# )
247+
248+
public_class_method def self.delete_issue(opts = {})
249+
base_api_uri = opts[:base_api_uri]
250+
251+
token = opts[:token]
252+
token ||= PWN::Plugins::AuthenticationHelper.mask_password(
253+
prompt: 'Personal Access Token'
254+
)
255+
256+
issue = opts[:issue]
257+
258+
raise 'ERROR: issue cannot be nil.' if issue.nil?
259+
260+
rest_call(
261+
http_method: :delete,
262+
base_api_uri: base_api_uri,
263+
token: token,
264+
rest_call: "issue/#{issue}"
265+
)
266+
rescue StandardError => e
267+
raise e
268+
end
269+
208270
# Author(s):: 0day Inc. <[email protected]>
209271

210272
public_class_method def self.authors
@@ -240,6 +302,13 @@ module JiraServer
240302
additional_fields: 'optional - additional fields to set in the issue (e.g. labels, components, custom fields, etc.)'
241303
)
242304
305+
issue_resp = #{self}.update_issue(
306+
base_api_uri: 'required - base URI for Jira (e.g. https:/jira.corp.com/rest/api/latest)',
307+
token: 'required - bearer token',
308+
issue: 'required - issue to update (e.g. Bug, Issue, Story, or Epic ID)',
309+
fields: 'required - fields to update in the issue (e.g. summary, description, labels, components, custom fields, etc.)'
310+
)
311+
243312
**********************************************************************
244313
* For more information on the Jira Server REST API, see:
245314
* https://developer.atlassian.com/server/jira/platform/rest-apis/

lib/pwn/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module PWN
4-
VERSION = '0.5.294'
4+
VERSION = '0.5.295'
55
end

0 commit comments

Comments
 (0)