Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query the csvimport module via REST API mechanism - Error: "Unsupported attributes type" #604

Open
pelletier6666 opened this issue Feb 23, 2023 · 0 comments

Comments

@pelletier6666
Copy link

pelletier6666 commented Feb 23, 2023

What I am trying to do

I've read from the training material related to MISP modules that we can query a module via REST API.
Based on the example query provided on the github to test the DNS module, I would like to query the csvimport module.

The way i do it
By inspecting csvimport.py handler function source code, i've made up a json payload that look like this:

{
	"data": "",
	"config": {
		"header":",ip-dst,ip-dst|port,,datetime,malware-type",
		"has_header": 0, 
		"special_delimiter": ","
	},

	"file": "/var/www/MISP/ipblocklist.csv",
	"module": "csvimport"
}

I request the csvimport by this command: curl -s http://127.0.0.1:6666/query -H "Content-Type: application/json" --data @body7.json -X POST

The problem is that i get stuck into the start of the handler (I don't know what to put in the data field in order to pass the first if else) :

def handler(q=False):
    if q is False:
        return False
    request = json.loads(q)
    if request.get('data'):
        try:
            data = base64.b64decode(request['data']).decode('utf-8')
        except UnicodeDecodeError:
            misperrors['error'] = "Input is not valid UTF-8"
            return misperrors
    else:
        misperrors['error'] = "Unsupported attributes type" <-- Here comes the error 
        return misperrors
        ...

Any Help would be more than welcome
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant