MCPcopy Index your code
hub / github.com/sqlmapproject/sqlmap / createGithubIssue

Function createGithubIssue

lib/core/common.py:3953–4032  ·  view source on GitHub ↗

Automatically create a Github issue with unhandled exception information

(errMsg, excMsg)

Source from the content-addressed store, hash-verified

3951 return random.sample(kb.userAgents, 1)[0]
3952
3953def createGithubIssue(errMsg, excMsg):
3954 """
3955 Automatically create a Github issue with unhandled exception information
3956 """
3957
3958 try:
3959 issues = getFileItems(paths.GITHUB_HISTORY, unique=True)
3960 except:
3961 issues = []
3962 finally:
3963 issues = set(issues)
3964
3965 _ = re.sub(r"'[^']+'", "''", excMsg)
3966 _ = re.sub(r"\s+line \d+", "", _)
3967 _ = re.sub(r'File ".+?/(\w+\.py)', r"\g<1>", _)
3968 _ = re.sub(r".+\Z", "", _)
3969 _ = re.sub(r"(Unicode[^:]*Error:).+", r"\g<1>", _)
3970 _ = re.sub(r"= _", "= ", _)
3971
3972 key = hashlib.md5(getBytes(_)).hexdigest()[:8]
3973
3974 if key in issues:
3975 return
3976
3977 msg = "\ndo you want to automatically create a new (anonymized) issue "
3978 msg += "with the unhandled exception information at "
3979 msg += "the official Github repository? [y/N] "
3980 try:
3981 choice = readInput(msg, default='N', checkBatch=False, boolean=True)
3982 except:
3983 choice = None
3984
3985 if choice:
3986 _excMsg = None
3987 errMsg = errMsg[errMsg.find("\n"):]
3988
3989 req = _urllib.request.Request(url="https://api.github.com/search/issues?q=%s" % _urllib.parse.quote("repo:sqlmapproject/sqlmap Unhandled exception (#%s)" % key), headers={HTTP_HEADER.USER_AGENT: fetchRandomAgent()})
3990
3991 try:
3992 content = _urllib.request.urlopen(req).read()
3993 _ = json.loads(content)
3994 duplicate = _["total_count"] > 0
3995 closed = duplicate and _["items"][0]["state"] == "closed"
3996 if duplicate:
3997 warnMsg = "issue seems to be already reported"
3998 if closed:
3999 warnMsg += " and resolved. Please update to the latest "
4000 warnMsg += "development version from official GitHub repository at '%s'" % GIT_PAGE
4001 logger.warning(warnMsg)
4002 return
4003 except:
4004 pass
4005
4006 data = {"title": "Unhandled exception (#%s)" % key, "body": "```%s\n```\n```\n%s```" % (errMsg, excMsg)}
4007 token = getText(zlib.decompress(decodeBase64(GITHUB_REPORT_OAUTH_TOKEN[::-1], binary=True))[0::2][::-1])
4008 req = _urllib.request.Request(url="https://api.github.com/repos/sqlmapproject/sqlmap/issues", data=getBytes(json.dumps(data)), headers={HTTP_HEADER.AUTHORIZATION: "token %s" % token, HTTP_HEADER.USER_AGENT: fetchRandomAgent()})
4009
4010 try:

Callers 1

mainFunction · 0.90

Calls 13

getBytesFunction · 0.90
getTextFunction · 0.90
decodeBase64Function · 0.90
getFileItemsFunction · 0.85
fetchRandomAgentFunction · 0.85
openFileFunction · 0.85
findMethod · 0.80
infoMethod · 0.80
readInputFunction · 0.70
getSafeExStringFunction · 0.70
readMethod · 0.45
searchMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…