Submit a bug automatically.

Get help from other users here.

Moderators: Developer, Contributor

Post Reply
cydside
Posts: 3
Joined: 02 Sep 2009, 11:55

Submit a bug automatically.

Post by cydside »

Hi to all,
I'm using Mantis 1.1.8 to keep my software bugs and I'm working to automate a bug report from my C++ application when a problem happens to someone who is using it. So I've debugged the HTTP traffic during the normal work on Mantis and the following are the HTTP Header and Object:

HTTP Header

Code: Select all

POST /mantis/bug_report.php HTTP/1.1
POST 
/mantis/bug_report.php 
HTTP/1.1
Host: www.example.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 showdtl=Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 showdtl=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: it-it,it;q=0.8,en-us;q=0.5,en;q=0.3 showdtl=it-it,it;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://www.example.com/mantis/bug_report_page.php
Cookie: MANTIS_BUG_LIST_COOKIE=4%2C2%2C1; PHPSESSID=d2218bf1c4171de429fe7932c8af7d45; MANTIS_STRING_COOKIE=2d895684f34453698ae611bbb0231b7888a62fe7831b0cfd8e9e06bde5616de4
Content-Type: multipart/form-data; boundary=---------------------------207982800927157
Content-Length: 1615
HTTP Object

Code: Select all

-----------------------------207982800927157
Content-Disposition: form-data; name="bug_report_token"

20090831-c9fc2e04d74851c3b8b24d62b05a13e4ae349a70
-----------------------------207982800927157
Content-Disposition: form-data; name="m_id"

0
-----------------------------207982800927157
Content-Disposition: form-data; name="project_id"

1
-----------------------------207982800927157
Content-Disposition: form-data; name="handler_id"

0
-----------------------------207982800927157
Content-Disposition: form-data; name="category"

Database Query
-----------------------------207982800927157
Content-Disposition: form-data; name="reproducibility"

70
-----------------------------207982800927157
Content-Disposition: form-data; name="severity"

50
-----------------------------207982800927157
Content-Disposition: form-data; name="priority"

30
-----------------------------207982800927157
Content-Disposition: form-data; name="summary"

Riassunto
-----------------------------207982800927157
Content-Disposition: form-data; name="description"

Descrizione
-----------------------------207982800927157
Content-Disposition: form-data; name="additional_info"


-----------------------------207982800927157
Content-Disposition: form-data; name="max_file_size"

5000000
-----------------------------207982800927157
Content-Disposition: form-data; name="file"; filename=""
Content-Type: application/octet-stream


-----------------------------207982800927157
Content-Disposition: form-data; name="view_state"

10
-----------------------------207982800927157--
So I've wrote the code to login(it works :D ) and the code to submit a bug but I've recieved the following message in "My View" page:
APPLICATION ERROR #2800

Invalid form security token. Did you submit the form twice by accident?

Please use the "Back" button in your web browser to return to the previous page. There you can correct whatever problems were identified in this error or select another action. You can also click an option from the menu bar to go directly to a new section.
Ok, I,ve tried to read the bug_report.php code(I'm not so expert) to understand how to fix my application. I suspect, probably, that it depends on the first paramer "bug_report_token":

Code: Select all

-----------------------------207982800927157
Content-Disposition: form-data; name="bug_report_token"

20090831-c9fc2e04d74851c3b8b24d62b05a13e4ae349a70
due to form_security_validate( 'bug_report' ); funcion as follow

Code: Select all

	# --------------------------------------------------------
	# $Id: bug_report.php,v 1.49.2.1 2007-10-13 22:32:51 giallu Exp $
	# --------------------------------------------------------

	# This page stores the reported bug

	require_once( 'core.php' );

	$t_core_path = config_get( 'core_path' );

	require_once( $t_core_path.'string_api.php' );
	require_once( $t_core_path.'file_api.php' );
	require_once( $t_core_path.'bug_api.php' );
	require_once( $t_core_path.'custom_field_api.php' );

	form_security_validate( 'bug_report' );

	access_ensure_project_level( config_get('report_bug_threshold' ) );

	$t_bug_data = new BugData;
	$t_bug_data->build				= gpc_get_string( 'build', '' );
	$t_bug_data->platform				= gpc_get_string( 'platform', '' );
Is it true? Can you help me? It's very important, for me, to automate the bur reporting action, thanks in advance. Danilo
deboutv
Posts: 507
Joined: 15 Jan 2007, 14:31
Location: La Ciotat, FRANCE
Contact:

Re: Submit a bug automatically.

Post by deboutv »

I'm not sure this is the good way. If your database (MySQL or other) is available on internet, you can directly use the sql client to add a bug. If not, you can try to make your own PHP page (which will handle authentication and bug report) and call this page through your application.
Want more plugins to customize Mantis?
=> http://deboutv.free.fr/mantis/

Mantis: 1.1.0, 1.1.0a2
PHP: 5.0.4
SQL: MySQL 5.0.19
OS: Linux
cydside
Posts: 3
Joined: 02 Sep 2009, 11:55

Re: Submit a bug automatically.

Post by cydside »

Thanks, I will try the SQL client solution!
deboutv
Posts: 507
Joined: 15 Jan 2007, 14:31
Location: La Ciotat, FRANCE
Contact:

Re: Submit a bug automatically.

Post by deboutv »

Ok, look in the core/bug_api.php file to see what you should insert in the SQL tables (there is a lot of table to set: bug_table, history_table, ...).
Want more plugins to customize Mantis?
=> http://deboutv.free.fr/mantis/

Mantis: 1.1.0, 1.1.0a2
PHP: 5.0.4
SQL: MySQL 5.0.19
OS: Linux
vboctor
Site Admin
Posts: 1293
Joined: 13 Feb 2005, 22:11
Location: Redmond, Washington
Contact:

Re: Submit a bug automatically.

Post by vboctor »

Your C++ application should use the MantisBT SOAP API to report issues.
Migrate your MantisBT to the MantisHub Cloud
Post Reply