GithubHelp home page GithubHelp logo

yeti-platform / pyeti Goto Github PK

View Code? Open in Web Editor NEW
18.0 18.0 12.0 191 KB

Python bindings for Yeti's API

License: Apache License 2.0

Python 100.00%
api enrichment infosec intelligence python threat-hunting threat-sharing threatintel

pyeti's Issues

Pull data from YETI

Can anyone share a working example of yeti api that pulls data from Yeti.

I don't know what arguments to be where can i find them in my local hosted yeti.

Sharing Screenshots would be more helpful.

Tried add entity_add functionality but not working.

I am trying to add more functionality to the YetiApi class.
When I tried the get entity it worked, but for adding a entity it gives error

ERROR:root:An error occurred (500):

Any pointers towards this would be welcome, There was no documentation of json values of entity object so I did a get entity and used similar json object in entity_add

Following are my functions added to api.py

    def entity_details(self, id):
        """Get details on an entity.
        Args:
            id: A string representing the entity's ObjectID

        Returns:
            JSON representation of the requested entity
        """
        return self._make_get("entity/{}".format(id))

    def entity_add(self, name,etype,description,aliases=[], tags=[],context={},source="API"):
        """Add an entity to the dataset

        Args:
            name: the name of entity
            etype: type of entity ('Actor','TTP' etc)
            description: description of Entity
            tags: An array of strings representing tags
            context: A dictionary object with context information
            source: A string representing the source of the data. Defaults to
                   "API".

        Returns:
            JSON representation of the created observable.
        """
        json = {
            'description':description,
            'tags':tags,
            'aliases':aliases,
            'type':etype,
            'name':name,
            'context':context,
            'source':source
        }

        return self._make_post('entity/', json=json)

http://localhost:5000/api/entity/ not working as expected

I have tried to add entity using both pyet and curl -POST but neither of them worked. I am able to get_entity but if I add the function entity_add with the required parameters ( name, description & tags) - it doesnt work. Moreover, As one of your suggestions in one of the issues - that, this will add an entity but to add sub-object ( malware, threat actor etc) _cls needs to be set manually. Can you please explain this in bit detail?

The function that I added

def entity_add(self,name,description,tags=None, source="API"):

    if tags is None:
        tages = []
    json = {

        "name": name,
                    "description": description,
        "tags": tags,
        "source": source
    }
    return self._make_post('entity/', json=json)

When I call this function - I get followin error

results = api.entity_add("malware","malwaredescription",['tags1'])
ERROR:root:An error occurred (500): http://localhost:5000/api/entity/

Same way, when I tried to add with curl

$$$curl -d '{"value":"malware","tags":['a','b']}' -H "Content-type: application/json" -X POST http://localhost:5000/api/entity/

<title>400 Bad Request</title> h1Bad Requesth1

The browser (or proxy) sent a request that this server could not understand.

$$$curl -d '{"value":"malware"}' -H "Content-type: application/json" -X POST http://localhost:5000/api/entity/

<title>500 Internal Server Error</title> h1Internal Server Error

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

Another Try using Curl

entity.json
{
"value":"malwre"
"tags":['a','b']
}

$$$$curl -d "@entity.json" -H "Content-type: application/json" -X POST http://localhost:5000/api/entity/

<title>400 Bad Request</title> h1Bad Request

The browser (or proxy) sent a request that this server could not understand.

Can you please help ?

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.