Git Product home page Git Product logo

Comments (30)

z4r avatar z4r commented on August 23, 2024

Hi @avorum, do you have any log of this call?

from python-rtkit.

avorum avatar avorum commented on August 23, 2024

Do you mean a log of the request sent to the RT server as a result of this script?

from python-rtkit.

z4r avatar z4r commented on August 23, 2024

yes, the output log of the script

from python-rtkit.

avorum avatar avorum commented on August 23, 2024

My company seems to only have error logs for our RT Server and they have no entries corresponding to the requests made by my script. Is there a way to modify any of the files in the module or some way to interact with the module to figure out what's going on? Given the nature of my corporate environment it would be highly difficult to get the logging policies changed for debugging this issue.

from python-rtkit.

avorum avatar avorum commented on August 23, 2024

@z4r I'm going to try and get some proper logging for this issue from the people who manage our RT service, post if you have another idea of how to figure out what's going on.

from python-rtkit.

avorum avatar avorum commented on August 23, 2024

after running some tests ( where i changed some custom field names) I've found that the code only breaks on fields with special characters (ie () / or ?)

from python-rtkit.

z4r avatar z4r commented on August 23, 2024

Anyway i'm talking about python log, not server one.
I need to reproduce it to add a new test.

from python-rtkit.

avorum avatar avorum commented on August 23, 2024

Here's what I got from logfiles:

access_log:

172.23.80.35 - - [30/Jul/2013:09:08:11 -0400] "POST /REST/1.0/ HTTP/1.1" 200 79 "-" "Python-urllib/2.7"
172.25.80.200 - - [30/Jul/2013:09:08:11 -0400] "POST /REST/1.0/ticket/new HTTP/1.1" 200 341 "-" "Python-urllib/2.7"

No corresponding entries in the error_log

from python-rtkit.

avorum avatar avorum commented on August 23, 2024

I apologize then, I'm rather new to python. What exactly are you looking for? Is there a log file made by python automatically? Or are you looking for some specific information? There is some logging included in my output in the original post.

from python-rtkit.

z4r avatar z4r commented on August 23, 2024

When you run the script did you have something before the traceback output?

from python-rtkit.

avorum avatar avorum commented on August 23, 2024

Wow, I thought I included that, my bad.

{'content': {'Queue': 'Vulnerabilities', 'CF-Priority': 'Low -Needs to be c
ompleted in > 30', 'CF-Is This Maintenance?': 'Not_maintenance', 'CF-Device or A
rea': 'My Device', 'Owner': 'jgreen', 'Text': "I'm a thing", 'CF-Vulnerability
 Risk': 'Low', 'CF-Time Estimated': 'Days', 'CF-CVSS Score': '2.6', 'Subject': '
Test Vulnerability for Script Dev'}}
[DEBUG] POST ticket/new
[DEBUG] {'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8', 'Ac
cept': 'text/plain'}
[DEBUG] "content=Queue: Vulnerabilities\nCF-Priority: Low -Needs to be comp
leted in > 30\nCF-Is This Maintenance?: Not_maintenance\nCF-Device or Area: My Device\nOwner: jgreen\nText: I'm a thing\nCF-Vulnerability Risk: Low\nCF-Time E
stimated: Days\nCF-CVSS Score: 2.6\nSubject: Test Vulnerability for Script Dev"
[INFO] POST
[INFO] https://rt.myrtserver.com/REST/1.0/ticket/new
[DEBUG] HTTP_STATUS: 200 OK
[DEBUG] "RT/3.6.6 409 Syntax Error\n\n# Syntax error.\n\nQueue: Vulnerabilities\
nCF-Priority: Low -Needs to be completed in > 30\n>> CF-Is This Maintenance
?: Not_maintenance\nCF-Device or Area: My Device\nOwner: jgreen\nText: I'm a t
hing\nCF-Vulnerability Risk: Low\nCF-Time Estimated: Days\nCF-CVSS Score: 2.6\nS
ubject: Test Vulnerability for Script Dev\n\n"
Traceback (most recent call last):
  File "resttest.py", line 34, in <module>
    response = resource.post(path='ticket/new', payload=content,)
  File "build\bdist.win32\egg\rtkit\resource.py", line 29, in post
  File "build\bdist.win32\egg\rtkit\resource.py", line 49, in request
  File "build\bdist.win32\egg\rtkit\resource.py", line 104, in __init__
  File "build\bdist.win32\egg\rtkit\parser.py", line 49, in parse
  File "build\bdist.win32\egg\rtkit\parser.py", line 79, in decode_comment
ValueError: need more than 1 value to unpack

from python-rtkit.

titilambert avatar titilambert commented on August 23, 2024

Hello !

Maybe you could check this pull request #32.

Bye

from python-rtkit.

avorum avatar avorum commented on August 23, 2024

@titilambert does updating the line in the module downloaded on my system and running python setup.py install accomplish what's needed to fix the install on my system as regarding the commit in request #32?

from python-rtkit.

titilambert avatar titilambert commented on August 23, 2024

Normally yes :)

from python-rtkit.

z4r avatar z4r commented on August 23, 2024

HI @avorum, could you try it again?

from python-rtkit.

avorum avatar avorum commented on August 23, 2024

After including those updates I now get the following output:

{'content': {'Queue': 'Vulnerabilities', 'CF-Priority': 'Low -Needs to be c
ompleted in > 30', 'CF-Is This Maintenance?': 'Not_maintenance', 'CF-Device or A
rea': 'My Device', 'Owner': 'jgreen', 'Text': "I'm a thing", 'CF-Vulnerability
 Risk': 'Low', 'CF-Time Estimated': 'Days', 'CF-CVSS Score': '2.6', 'Subject': '
Test Vulnerability for Script Dev'}}
[DEBUG] POST ticket/new
[DEBUG] {'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8', 'Ac
cept': 'text/plain'}
[DEBUG] "content=CF-CVSS%20Score: 2.6\nCF-Device%20or%20Area: My%20Device\nTex
t: I'm a thing\nCF-Time%20Estimated: Days\nQueue: Vulnerabilities\nCF-Vulnerabil
ity%20Risk: Low\nOwner: jgreen\nCF-HDMS%20Priority: Low%20-Needs%20to%20be%20com
pleted%20in%20%3E%2030\nCF-Is%20This%20Maintenance%3F: Not_maintenance\nSubject:
 Test Vulnerability for Script Dev"
[INFO] POST
[INFO] https://rt.hdms.com/REST/1.0/ticket/new
[DEBUG] HTTP_STATUS: 200 OK
[DEBUG] "RT/3.6.6 409 Syntax Error\n\n# Syntax error.\n\nCF-CVSS Score: 2.6\nCF-
Device or Area: My Device\nText: I'm a thing\nCF-Time Estimated: Days\nQueue:
Vulnerabilities\nCF-Vulnerability Risk: Low\nOwner: jgreen\nCF-Priority: Lo
w -Needs to be completed in > 30\n>> CF-Is This Maintenance?: Not_maintenance\nS
ubject: Test Vulnerability for Script Dev\n\n"
[DEBUG] RESOURCE_STATUS: 409 Syntax Error
[INFO] [[('CF-Is This Maintenance?', 'Not_maintenance')]]
[INFO] [[('CF-Is This Maintenance?', 'Not_maintenance')]]

This is the results for uncommenting the "Is This Maintenance?" field in the code. Swap out the references to that for whatever one is uncommented. This error has problems on the same five fields as before (Is This Maintenenance, Approved, Type of change/risk, Discovered by (Company), Discovered by (Program)).

from python-rtkit.

avorum avatar avorum commented on August 23, 2024

@z4r do you know what might cause an ERROR 409 from RT?

from python-rtkit.

z4r avatar z4r commented on August 23, 2024

Ok! I found the problem and it's not a problem of encoding.
In the RT REST interface CF-Is This Maintenance? must be written CF.{Is This Maintenance?}

I got it reading a tkt:

[INFO] id: ticket/102
[INFO] Queue: Developers
[INFO] Owner: Nobody
[INFO] Creator: john.foo
[INFO] Subject: W00t
[INFO] Status: new
    ...
[INFO] CF.{Priority?}: aaa

Now I need a while to understand how to hide this to end-dev.

Could you try to format your CFs?

from python-rtkit.

avorum avatar avorum commented on August 23, 2024

Changed "CF-Is This Maintenance?" to "CF.{Is This Maintenance?}" in my script yields the same error.

from python-rtkit.

z4r avatar z4r commented on August 23, 2024

It could be a problem with the RT version....

from rtkit.resource import RTResource
from rtkit.authenticators import CookieAuthenticator
from rtkit.errors import RTResourceError

from rtkit import set_logging
import logging
set_logging('debug')
logger = logging.getLogger('rtkit')
#resource = RTResource('http://rt.easter-eggs.org/demos/stable/REST/1.0/', 'admin', 'admin', CookieAuthenticator)
resource = RTResource('http://rt.easter-eggs.org/demos/oldstable/REST/1.0/', 'admin', 'admin', CookieAuthenticator)

content = {
    'content': {
        'CF.{Is This Maintenance?}': 'ccc',
        }
    }
try:
    response = resource.post(path='ticket/8', payload=content,)
    #response = resource.get(path='ticket/8')
    for k, v in response.parsed[0]:
        logger.info('{0}: {1}'.format(k, v))
except RTResourceError as e:
    logger.error(e.response.status_int)
    logger.error(e.response.status)
    logger.error(e.response.parsed)

Here the output with RT/4.0

[DEBUG] POST ticket/102
[DEBUG] {'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8', 'Accept': 'text/plain'}
[DEBUG] 'content=CF.{Is This Maintenance?}: ccc'
[INFO] POST
[INFO] http://rt.easter-eggs.org/demos/stable/REST/1.0/ticket/102
[DEBUG] HTTP_STATUS: 200 OK
[DEBUG] 'RT/4.0.13-48-g793e087 200 Ok\n\n# Ticket 102 updated.\n\n'
[DEBUG] RESOURCE_STATUS: 200 Ok
[INFO] [[]]

And here the same code on RT/3.8

[DEBUG] POST ticket/8
[DEBUG] {'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8', 'Accept': 'text/plain'}
[DEBUG] 'content=CF.{Is This Maintenance?}: ccc'
[INFO] POST
[INFO] http://rt.easter-eggs.org/demos/oldstable/REST/1.0/ticket/8
[DEBUG] HTTP_STATUS: 200 OK
[ERROR] "Can't use an undefined value as an ARRAY reference at /home/rt-demo/3.8/rt/share/html/REST/1.0/dhandler line 189.

Stack:
  [/home/rt-demo/3.8/rt/share/html/REST/1.0/dhandler:189]
  [/home/rt-demo/3.8/rt/share/html/REST/1.0/autohandler:54]
  [/home/rt-demo/3.8/rt/bin/../lib/RT/Interface/Web.pm:547]
  [/home/rt-demo/3.8/rt/bin/../lib/RT/Interface/Web.pm:266]
  [/home/rt-demo/3.8/rt/share/html/autohandler:53]
" is not valid
[DEBUG] "Can't use an undefined value as an ARRAY reference at /home/rt-demo/3.8/rt/share/html/REST/1.0/dhandler line 189.\n\nStack:\n  [/home/rt-demo/3.8/rt/share/html/REST/1.0/dhandler:189]\n  [/home/rt-demo/3.8/rt/share/html/REST/1.0/autohandler:54]\n  [/home/rt-demo/3.8/rt/bin/../lib/RT/Interface/Web.pm:547]\n  [/home/rt-demo/3.8/rt/bin/../lib/RT/Interface/Web.pm:266]\n  [/home/rt-demo/3.8/rt/share/html/autohandler:53]\n"
[DEBUG] RESOURCE_STATUS: Can't use an undefined value as an ARRAY reference at /home/rt-demo/3.8/rt/share/html/REST/1.0/dhandler line 189.

Stack:
  [/home/rt-demo/3.8/rt/share/html/REST/1.0/dhandler:189]
  [/home/rt-demo/3.8/rt/share/html/REST/1.0/autohandler:54]
  [/home/rt-demo/3.8/rt/bin/../lib/RT/Interface/Web.pm:547]
  [/home/rt-demo/3.8/rt/bin/../lib/RT/Interface/Web.pm:266]
  [/home/rt-demo/3.8/rt/share/html/autohandler:53]

[INFO] [[]]

Can you adapt my script (url, user, password and tkt_number) to verify what's happening with RT/3.6?

from python-rtkit.

z4r avatar z4r commented on August 23, 2024

Anyway only ? seems to break the code...

from python-rtkit.

avorum avatar avorum commented on August 23, 2024

When I adapt your code it throws an index error on the line "for k, v in response.parsed[0]". And in addition to the ?, / and () seem to break it as well.

from python-rtkit.

z4r avatar z4r commented on August 23, 2024

download the new code from this repo and change from the script

    for k, v in response.parsed[0]:
        logger.info('{0}: {1}'.format(k, v))

with

logger.info(response.parsed)

from python-rtkit.

avorum avatar avorum commented on August 23, 2024

Alright it's working now. What exactly are you looking for? logger.info(response.parsed) is what I had before so the output is just the same as before. Here's the output from running it regardless, current code is shown as well. Your output clearly has some stack information but I'm not sure how to get that output out of this code.

from rtkit.resource import RTResource
from rtkit.authenticators import BasicAuthenticator, CookieAuthenticator
from rtkit.errors import RTResourceError

from rtkit import set_logging
import logging
set_logging('debug')
logger = logging.getLogger('rtkit')

resource = RTResource('https://rt.myurl.com/REST/1.0/', 'jgreen', 'pass', CookieAuthenticator)

#create a ticket
content = {
    'content': {
        'CF-Is This Maintenance?' : 'ccc',
        }
    }
try:
    response = resource.post(path='ticket/8501', payload=content,)
    logger.info(response.parsed)
except RTResourceError as e:
    logger.error(e.response.status_int)
    logger.error(e.response.status)
    logger.error(e.response.parsed)

[DEBUG] POST ticket/8501
[DEBUG] {'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8', 'Ac
cept': 'text/plain'}
[DEBUG] 'content=CF-Is This Maintenance?: ccc'
[INFO] POST
[INFO] https://rt.myurl.com/REST/1.0/ticket/8501
[DEBUG] HTTP_STATUS: 200 OK
[DEBUG] 'RT/3.6.6 409 Syntax Error\n\n# Syntax error.\n\n>> CF-Is This Maintenan
ce?: ccc\n\n'
[DEBUG] RESOURCE_STATUS: 409 Syntax Error
[INFO] [[('CF-Is This Maintenance?', 'ccc')]]
[INFO] [[('CF-Is This Maintenance?', 'ccc')]]

from python-rtkit.

z4r avatar z4r commented on August 23, 2024

Could you try with a CF without ? ?

from python-rtkit.

avorum avatar avorum commented on August 23, 2024

I did some testing and it works fine with any CF that doesn't include ?, /, or ().

from python-rtkit.

z4r avatar z4r commented on August 23, 2024

With CF.{...} form too?

from python-rtkit.

avorum avatar avorum commented on August 23, 2024

No I hadn't. Changing to CF.{...} form triggers the Error 409 in a payload that otherwise runs without issues.

from python-rtkit.

z4r avatar z4r commented on August 23, 2024

I guess 3.6 it's top old and top buggy to ask to patch.

from python-rtkit.

avorum avatar avorum commented on August 23, 2024

Ok, it's a shame, I guess we'll have to upgrade.

from python-rtkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.