Skip to content

Commit

Permalink
[api] drop api-side issue parser
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianschroeter committed Jan 25, 2012
1 parent b57014e commit 592104b
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 116 deletions.
3 changes: 3 additions & 0 deletions docs/api/api/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,9 @@ Parameters:
dontupdatesource: Do not update origin package, optional (copy only)
comment: comment for history, optional
meta: switch to meta files
view: may be "xml" for structured answered (for diff commands)
withissues: set to get issues parsed from changelogs (for diff commands)
onlyissues: used to limit to issues (for diff commands)



Expand Down
23 changes: 0 additions & 23 deletions src/api/app/controllers/issue_trackers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,27 +117,4 @@ def destroy
end
end

# GET /issue_trackers/issues_in?text=...
# GET /issue_trackers/issues_in?text=bnc%231234
# GET /issue_trackers/issues_in?text=CVE-2011-1234
def issues_in
unless params[:text]
render_error :status => 400, :errorcode => "missing_parameter", :message => "Please provide a text parameter" and return
end
issues = IssueTracker.issues_in(params[:text], params[:diff_mode])

builder = Nokogiri::XML::Builder.new do |node|
node.issues({}) do |root|
issues.each do |i|
i.render_body(root)
end
end
end

render :text => builder.to_xml, :content_type => 'text/xml'

builder.to_xml

end

end
39 changes: 0 additions & 39 deletions src/api/app/models/issue_tracker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,45 +12,6 @@ class UnknownObjectError < Exception; end

DEFAULT_RENDER_PARAMS = {:except => [:id, :password, :user], :dasherize => true, :skip_types => true }

def self.issues_in(text, diff_mode = false)
ret = []
if diff_mode
old_issues, new_issues = [], []
end
# Ruby's string#scan method unfortunately doesn't return the whole match if a RegExp contains groups.
# RegExp#match does that but it doesn't advance the string if called consecutively. Thus we have to do
# it by hand...
text.lines.each do |line|
IssueTracker.all.each do |it|
substr = line
begin
match = it.matches?(substr)
if match
issue = Issue.find_or_create_by_name(match[-1], :issue_tracker => it)
if diff_mode
old_issues << issue if line.starts_with?('-')
new_issues << issue if line.starts_with?('+')
else
ret << issue
end
substr = substr[match.end(0)+1..-1]
end
end while match
end
end
if diff_mode
old_issue_names, new_issue_names = old_issues.map{|i| i.long_name}, new_issues.map{|i| i.long_name}

old_issues.each do |old_issue|
ret << old_issue if not new_issue_names.include?(old_issue.long_name)
end
new_issues.each do |new_issue|
ret << new_issue if not old_issue_names.include?(new_issue.long_name)
end
end
return ret.sort {|a, b| a.long_name <=> b.long_name}
end

def self.write_to_backend()
path = "/issue_trackers"
logger.debug "Write issue tracker information to backend..."
Expand Down
49 changes: 0 additions & 49 deletions src/api/test/functional/issue_trackers_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,53 +92,4 @@ def test_create_and_update_new_trackers
assert_response :success
end

def test_get_issues_in_text
ActionController::IntegrationTest::reset_auth
text = <<EOF
@@ -1,4 +1,12 @@
-------------------------------------------------------------------
+Fri Nov 4 08:33:52 UTC 2011 - lijewski.stefan@gmail.com
+
+- fix possible overflow and DOS in pam_env (bnc#724480)
+ CVE-2011-3148, CVE-2011-3149
+- fix pam_xauth not checking return value of setuid (bnc#631802)
+ CVE-2010-3316
+ blabla bnc#666
+
+-------------------------------------------------------------------
Thu Nov 27 15:56:51 CET 2008 - mc@suse.de
- enhance the man page for limits.conf (bnc#448314)")
- bnc#12345, bnc#666
EOF
get '/issue_trackers/issues_in', :text => text
assert_response 401
prepare_request_with_user "adrian", "so_alone"
get '/issue_trackers/issues_in', :text => text
assert_response :success
assert_tag :tag => "issue_tracker", :content => "bnc"
assert_tag :tag => "issue_tracker", :content => "cve"
assert_tag :tag => "long_name", :content => "bnc#724480"
assert_tag :tag => "name", :content => "448314"
assert_tag :tag => "name", :content => "631802"
assert_tag :tag => "name", :content => "724480"
assert_tag :tag => "name", :content => "CVE-2011-3148"
assert_tag :tag => "name", :content => "CVE-2011-3149"
assert_tag :tag => "name", :content => "CVE-2010-3316"
assert_tag :tag => "long_name", :content => "bnc#12345"
assert_tag :tag => "long_name", :content => "bnc#666"
assert_no_tag :tag => "password"

get '/issue_trackers/issues_in', :text => text, :diff_mode => true
assert_response :success
assert_no_tag :tag => "name", :content => "448314"
assert_tag :tag => "name", :content => "631802"
assert_tag :tag => "name", :content => "724480"
assert_tag :tag => "name", :content => "CVE-2011-3148"
assert_tag :tag => "name", :content => "CVE-2011-3149"
assert_tag :tag => "name", :content => "CVE-2010-3316"
assert_tag :tag => "long_name", :content => "bnc#12345"
assert_no_tag :tag => "long_name", :content => "bnc#666"
assert_no_tag :tag => "password"
end
end
5 changes: 0 additions & 5 deletions src/webui/app/models/issue_tracker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,5 @@ def make_stub(opt)
return reply
end

def issues_in(text)
path = "/issue_trackers/issues_in?format=json&text=#{URI.escape(text)}"
response = ActiveXML::Config::transport_for(:issuetracker).direct_http(URI(path))
return ActiveSupport::JSON.decode(response)
end
end
end

0 comments on commit 592104b

Please sign in to comment.