IntelligenceX / SDK

Public SDK for Intelligence X
https://intelx.io
405 stars 94 forks source link

TypeError: 'int' object is not subscriptable #557

Closed cmlh closed 7 months ago

cmlh commented 7 months ago

$ intelx.py -search apple.com

         _____      _       ___   __
        |_   _|    | |     | \ \ / /
          | | _ __ | |_ ___| |\ V / 
          | || '_ \| __/ _ \ |/   \ 
         _| || | | | ||  __/ / /^\ \
         \___/_| |_|\__\___|_\/   \/

           a command line client
               for intelx.io         

[16:09:35] Limit argument not supplied, setting default to 10 results.
[16:09:35] Starting search of "apple.com".
Traceback (most recent call last):
  File "/venv/bin/intelx.py", line 174, in <module>
    search = search(
             ^^^^^^^
  File "/venv/bin/intelx.py", line 39, in search
    s = ix.search(args.search, maxresults, buckets, timeout, datefrom, dateto, sort, media, terminate)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.11/site-packages/intelxapi.py", line 239, in search
    for a in r['records']:
             ~^^^^^^^^^^^
TypeError: 'int' object is not subscriptable

$

GitHub Issue https://github.com/zeropwn/intelx.py/issues/4 is not directly related but the latest intelx script causes this error.

Pull Request https://github.com/IntelligenceX/SDK/pull/517 is unrelated.

cmlh commented 7 months ago

Some sensitive or irrelevant text has been redacted with [SNIP]

Contents of intelx_search_input.json below:

{
 "term": "apple.com",
 "buckets": [],
 "lookuplevel": 0,
 "maxresults": 100,
 "timeout": 5,
 "datefrom": "",
 "dateto": "",
 "sort": 4,
 "media": 0,
 "terminate": []
}

httpie command below:

$ http POST "https://2.intelx.io/intelligent/search" "x-key:[SNIP]" @intelx_search_input.json

HTTP/1.1 200 OK
Content-Length: 112
Content-Type: application/json
[SNIP]

{
    "altterm": "",
    "alttermh": "",
    "id": "00000000-0000-0000-0000-000000000000",
    "softselectorwarning": false,
    "status": 1
}

Root casue is "status": 1 in JSON returned above

cmlh commented 7 months ago
$ intelx.py -apikey [snip] -search apple.com 

     _____      _       ___   __
    |_   _|    | |     | \ \ / /
      | | _ __ | |_ ___| |\ V /
      | || '_ \| __/ _ \ |/   \
     _| || | | | ||  __/ / /^\ \
     \___/_| |_|\__\___|_\/   \/

       a command line client
           for intelx.io         

[05:50:41] Limit argument not supplied, setting default to 10 results.
[05:50:41] Starting search of "apple.com".
[!] intelx.INTEL_SEARCH() Received 200 | Success

The workaround displays[!] intelx.INTEL_SEARCH() Received 200 | Success which is returned by get_error()

Kleissner commented 6 months ago

In the response to /intelligent/search, the status code status = 1 means "Invalid Term".

The API returns a JSON response so HTTP 200 is how it was designed and should be. The Python code/function should check for this status and return an error in the function and output an error message to the end user.

cmlh commented 6 months ago

In the response to /intelligent/search, the status code status = 1 means "Invalid Term".

The API returns a JSON response so HTTP 200 is how it was designed and should be. The Python code/function should check for this status and return an error in the function and output an error message to the end user.

The fix was inserted into get_error() i.e. https://github.com/IntelligenceX/Python/commit/28803f80861421dc26baeff79d926336124585db#diff-4bee3ab27586d1a7a090e2047cdbb14fa88a7da9c5be80e4ff2fda72c4541b1aR46-R47