Exemplo n.º 1
0
class MStarredStory(mongo.Document):
    """Like MStory, but not inherited due to large overhead of _cls and _type in
       mongoengine's inheritance model on every single row."""
    user_id = mongo.IntField()
    starred_date = mongo.DateTimeField()
    story_feed_id = mongo.IntField()
    story_date = mongo.DateTimeField()
    story_title = mongo.StringField(max_length=1024)
    story_content = mongo.StringField()
    story_content_z = mongo.BinaryField()
    story_original_content = mongo.StringField()
    story_original_content_z = mongo.BinaryField()
    story_content_type = mongo.StringField(max_length=255)
    story_author_name = mongo.StringField()
    story_permalink = mongo.StringField()
    story_guid = mongo.StringField(unique_with=('user_id', ))
    story_tags = mongo.ListField(mongo.StringField(max_length=250))

    meta = {
        'collection': 'starred_stories',
        'indexes': [('user_id', '-starred_date'), 'story_feed_id'],
        'ordering': ['-starred_date'],
        'allow_inheritance': False,
    }

    def save(self, *args, **kwargs):
        if self.story_content:
            self.story_content_z = zlib.compress(self.story_content)
            self.story_content = None
        if self.story_original_content:
            self.story_original_content_z = zlib.compress(
                self.story_original_content)
            self.story_original_content = None
        super(MStarredStory, self).save(*args, **kwargs)
Exemplo n.º 2
0
class MStory(mongo.Document):
    '''A feed item'''
    story_feed_id = mongo.IntField()
    story_date = mongo.DateTimeField()
    story_title = mongo.StringField(max_length=1024)
    story_content = mongo.StringField()
    story_content_z = mongo.BinaryField()
    story_original_content = mongo.StringField()
    story_original_content_z = mongo.BinaryField()
    story_content_type = mongo.StringField(max_length=255)
    story_author_name = mongo.StringField()
    story_permalink = mongo.StringField()
    story_guid = mongo.StringField()
    story_tags = mongo.ListField(mongo.StringField(max_length=250))

    meta = {
        'collection': 'stories',
        'indexes': ['story_date', ('story_feed_id', '-story_date')],
        'ordering': ['-story_date'],
        'allow_inheritance': False,
    }

    def save(self, *args, **kwargs):
        if self.story_content:
            self.story_content_z = zlib.compress(self.story_content)
            self.story_content = None
        if self.story_original_content:
            self.story_original_content_z = zlib.compress(
                self.story_original_content)
            self.story_original_content = None
        super(MStory, self).save(*args, **kwargs)
Exemplo n.º 3
0
class tags(mongoengine.Document):
    #__tablename__ = "tags"
    user_id = mongoengine.IntField(unique=True, null=False)
    name = mongoengine.StringField(null=False)
    desc = mongoengine.StringField(null=False)
    report_summary = mongoengine.BinaryField(default=False, null=False)
    report_detail = mongoengine.BinaryField(default=False, null=False)
    critical = mongoengine.BinaryField(default=False, null=False)
    created_at = mongoengine.DateTimeField(null=False)
    updated_at = mongoengine.DateTimeField(null=False)
Exemplo n.º 4
0
class session_events(mongoengine.Document):
    #__tablename__ = "session_events"
    session_id = mongoengine.IntField(unique=True, null=True)
    etype = mongoengine.StringField(null=False)
    command = mongoengine.BinaryField(null=True)
    output = mongoengine.BinaryField(null=True)
    remote_path = mongoengine.StringField(null=False)
    local_path = mongoengine.StringField(null=False)
    created_at = mongoengine.DateTimeField(null=False)
    updated_at = mongoengine.DateTimeField(null=False)
Exemplo n.º 5
0
class Macros(mongoengine.Document):
    #__tablename__="Macros"
    id = mongoengine.IntField(unique=True)
    owner = mongoengine.StringField()
    name = mongoengine.StringField()
    description = mongoengine.StringField()
    actions = mongoengine.BinaryField()
    prefs = mongoengine.BinaryField()
    created_at = mongoengine.DateTimeField(null=False)
    updated_at = mongoengine.DateTimeField(null=False)
Exemplo n.º 6
0
class MFeedPage(mongo.Document):
    feed_id = mongo.IntField(primary_key=True)
    page_data = mongo.BinaryField()

    meta = {
        'collection': 'feed_pages',
        'allow_inheritance': False,
    }

    def save(self, *args, **kwargs):
        if self.page_data:
            self.page_data = zlib.compress(self.page_data)
        super(MFeedPage, self).save(*args, **kwargs)

    @classmethod
    def get_data(cls, feed_id):
        data = None
        feed_page = cls.objects(feed_id=feed_id)

        if feed_page:
            data = feed_page[0].page_data and zlib.decompress(
                feed_page[0].page_data)

        if not data:
            dupe_feed = DuplicateFeed.objects.filter(duplicate_feed_id=feed_id)
            if dupe_feed:
                feed = dupe_feed[0].feed
                feed_page = MFeedPage.objects.filter(feed_id=feed.pk)
                if feed_page:
                    data = feed_page[0].page_data and zlib.decompress(
                        feed_page[0].page_data)

        return data
Exemplo n.º 7
0
class FramesVideo(me.Document):


    created_at          = me.DateTimeField(default=datetime.datetime.utcnow)
    frame               = me.BinaryField(required=True)
    equivalent2         = me.IntField(min_value=1, default=1)
    maincamera          = me.BooleanField(default=True)
Exemplo n.º 8
0
class vuln_details(mongoengine.Document):
    #__tablename__ ="vuln_details"
    vuln_id = mongoengine.IntField(null=False, unique=True)
    cvss_score = mongoengine.FloatField()
    cvss_vector = mongoengine.StringField(null=False)
    title = mongoengine.StringField(null=False)
    description = mongoengine.StringField(null=False)
    solution = mongoengine.StringField(null=False)
    proof = mongoengine.BinaryField()
    nx_console_id = mongoengine.IntField(null=False, unique=True)
    nx_device_id = mongoengine.IntField(null=False, unique=True)
    nx_vuln_id = mongoengine.StringField(null=False, unique=True)
    nx_severity = mongoengine.FloatField()
    nx_pci_severity = mongoengine.FloatField()
    nx_published = mongoengine.DateTimeField(null=False)
    nx_added = mongoengine.DateTimeField(null=False)
    nx_modified = mongoengine.DateTimeField(null=False)
    nx_tags = mongoengine.StringField(null=False)
    nx_vuln_status = mongoengine.StringField(null=False)
    nx_proof_key = mongoengine.StringField(null=False)
    src = mongoengine.StringField(null=False)
    nx_scan_id = mongoengine.IntField(null=False, unique=True)
    nx_vulnerable_since = mongoengine.DateTimeField(null=False)
    nx_pci_compliance_status = mongoengine.StringField(null=False)
    created_at = mongoengine.DateTimeField(null=False)
    updated_at = mongoengine.DateTimeField(null=False)
Exemplo n.º 9
0
class profiles(mongoengine.Document):
    #__tablename__= "profiles"
    id = mongoengine.IntField(unique=True)
    active = mongoengine.BooleanField(default=True)
    name = mongoengine.StringField(null=False)
    owner = mongoengine.StringField(null=False)
    settings = mongoengine.BinaryField()
Exemplo n.º 10
0
class UserORM(CustomDynamicDocument):

    username = db.StringField(required=True, unique=True)
    password = db.BinaryField(required=True)
    permissions = db.ListField()

    meta = {'collection': 'user', 'indexes': ['username']}
Exemplo n.º 11
0
class Avatar(me.Document):
    id = me.StringField(primary_key=True, default=lambda: uuid4().hex)
    content_type = me.StringField(default="image/png")
    body = me.BinaryField()
    owner = me.ReferenceField(Owner,
                              required=True,
                              reverse_delete_rule=me.CASCADE)
Exemplo n.º 12
0
class Features(mongoengine.Document):
    document = mongoengine.ReferenceField(Cache, reverse_delete_rule=mongoengine.CASCADE, required=True)
    feature = mongoengine.BinaryField(required=True)
    file = mongoengine.FileField(required=True)
    meta = {
        'db_alias': 'core',
        'collection': 'features'
    }
Exemplo n.º 13
0
class Suspicious(mongoengine.Document):
    image= mongoengine.BinaryField(required=True)
    date = mongoengine.DateTimeField(default=datetime.datetime.now)
    location= mongoengine.StringField()

    meta={
        'db_alias': 'core',
        'collection': 'suspicious'
    }
Exemplo n.º 14
0
class Image(mongo.Document):
    timestamp = mongo.DateTimeField(default=datetime.datetime.utcnow())
    xy = mongo.BinaryField()

    @classmethod
    def create(cls):
        arr_int_2d = gen_random_data()
        arr_binary = pickle.dumps(arr_int_2d, protocol=2)
        return Image(xy=arr_binary).save()
Exemplo n.º 15
0
class web_pages(mongoengine.Document):
    #__tablename__="web_pages"
    web_site_id = mongoengine.IntField(unique=True, null=False)
    path = mongoengine.StringField(null=False)
    query = mongoengine.StringField(null=False)
    code = mongoengine.IntField(null=False)
    cookie = mongoengine.StringField(null=False)
    auth = mongoengine.StringField(null=False)
    ctype = mongoengine.StringField(null=False)
    mtime = mongoengine.DateTimeField(null=False)
    location = mongoengine.StringField(null=False)
    headers = mongoengine.StringField(null=False)
    body = mongoengine.BinaryField()
    request = mongoengine.BinaryField()
    created_at = mongoengine.DateTimeField(null=False)
    updated_at = mongoengine.DateTimeField(null=False)
    """meta = (Index('index_web_pages_on_path', 'path'),Index('index_web_pages_on_query','query'))"""
    meta = {'indexes': [{'fields': ['path', 'query']}]}
Exemplo n.º 16
0
class Article(Document):
    """Test schema."""

    user = db.ReferenceField(User)
    addition = db.EmbeddedDocumentField(ArticleMetaData)
    title = db.StringField()
    date = db.DateTimeField()
    body = db.BinaryField()
    uuid = db.UUIDField()
Exemplo n.º 17
0
class UserModel(mongoengine.Document):
    @classmethod
    def post_save(cls, sender, document, **kwargs):
        globals.add_to_embeddings(username=document.user_name,
                                  encoding=pickle.loads(document.encoding))

    user_name = mongoengine.StringField(required=True)
    image = mongoengine.FileField(required=True)
    encoding = mongoengine.BinaryField(required=True)
    meta = {'db_alias': 'core', 'collection': 'users'}
Exemplo n.º 18
0
class Molecule(db.DynamicDocument):
    smiles = db.StringField()
    mol = db.BinaryField()
    #mfp2_2048 = db.StringField()
    #rdfp2_2048 = db.StringField()

    def get_mol(self):
        return Chem.Mol(self.mol)

    meta = {'indexes': ['smiles']}
Exemplo n.º 19
0
class URLMetadataDTO(mongo.Document):
    """A DTO wrapper for URLMetadata documents."""

    url = mongo.URLField(db_field='u')
    domain = mongo.StringField(db_field='d')
    last_visited = mongo.DateTimeField(db_field='v')
    score = mongo.IntField(db_field='s')
    update_freq = mongo.IntField(db_field='f')
    checksum = mongo.BinaryField(db_field='c')
    last_updated = mongo.DateTimeField(db_field='lu')
Exemplo n.º 20
0
class DBDirectory(mge.Document):
    btc_addr = mge.StringField()
    btc_addr_type = mge.StringField()
    btc_addr_is_segwit = mge.BooleanField()
    btc_addr_p2pkh = mge.StringField()
    btc_addr_p2wpkh = mge.StringField()
    btc_addr_p2sh = mge.StringField()
    btc_addr_p2wsh = mge.StringField()
    btc_addr_bech32 = mge.StringField()
    pbk = mge.BinaryField()
    hash160 = mge.BinaryField()
    pvk = mge.BinaryField()
    bal = mge.FloatField()
    bal_asof = mge.DateTimeField()
    utxo = mge.BooleanField(default=True)
    txis = mge.ListField()
    txos = mge.ListField()

    meta = {'db_alias': 'chinnus_nas', 'collection': 'btc_directory'}
Exemplo n.º 21
0
class Posts(mongoengine.Document):
    """Main model"""
    post = mongoengine.BinaryField(required=True)
    """Original File"""
    date = mongoengine.DateTimeField(default=datetime.datetime.now)
    user = mongoengine.ReferenceField(UserModel,
                                      reverse_delete_rule=mongoengine.CASCADE,
                                      required=True)
    location = mongoengine.StringField(required=True)
    meta = {'db_alias': 'core', 'collection': 'posts'}
Exemplo n.º 22
0
class SourceData(mongoengine.Document):

    time = mongoengine.DateTimeField(required=True,
                                     default=datetime.now)
    data = mongoengine.BinaryField(required=True)

    meta = {
        'db_alias': globals.DB.ALIAS,
        'collection': globals.DB.SOURCEDATA
    }
Exemplo n.º 23
0
class Order(mongoengine.Document):
    """
    订单类数据库模型:
        amount: 订单总金额 - float
        goods: 购买商品列表 - List[CacheedRef]
        status: 当前状态JSON字串 - str
        instance: 订单状态管理器的 pickle 对象 - bytes
    """
    amount = mongoengine.FloatField(min_value=0, required=True)
    goods = mongoengine.ListField(mongoengine.LazyReferenceField(stock.Stock))
    status = mongoengine.StringField(default=str)
    instance = mongoengine.BinaryField(default=bytes)
Exemplo n.º 24
0
class Product(mongo.DynamicDocument):
    """
    Definition of product schema.
    """
    name = mongo.StringField(required=True, max_length=100)
    search_term = mongo.ListField(required=False)
    last_update = mongo.DateTimeField(default=datetime.datetime.utcnow)
    quantity = mongo.StringField(required=False, max_length=50)
    comparison_quantity = mongo.FloatField(required=False)
    comparison_measure = mongo.StringField(required=False, max_length=50)
    shop = mongo.StringField(required=False, max_length=50)
    coop_link = mongo.URLField(required=False)
    ah_link = mongo.URLField(required=False)
    # shop_ids =  ListField(required=False)
    coop_id = mongo.IntField(required=False)
    ah_id = mongo.StringField(required=False)
    ah_image = mongo.BinaryField(required=False)
    coop_image = mongo.BinaryField(required=False)
    ah_name = mongo.StringField(required=False, max_length=100)
    coop_name = mongo.StringField(required=False, max_length=100)
    ah_ranking = mongo.IntField(required=False)
    coop_ranking = mongo.IntField(required=False)
Exemplo n.º 25
0
class listeners(mongoengine.Document):
    #__tablename__="listeners"
    workspace_id = mongoengine.IntField(null=False, default=1)
    task_id = mongoengine.IntField(unique=True)
    enabled = mongoengine.BooleanField(default=True)
    owner = mongoengine.StringField()
    payload = mongoengine.StringField()
    address = mongoengine.StringField()
    port = mongoengine.IntField()
    options = mongoengine.BinaryField()
    macro = mongoengine.StringField()
    created_at = mongoengine.DateTimeField(null=False)
    updated_at = mongoengine.DateTimeField(null=False)
Exemplo n.º 26
0
class User(mongoengine.Document):
    username = mongoengine.StringField(required=True)
    password = mongoengine.BinaryField(required=False)
    reputation = mongoengine.FloatField(required=False)
    amountLabeled = mongoengine.IntField(required=False)
    verified = mongoengine.IntField(required=False)
    misverified = mongoengine.IntField(required=False)

    meta = {
        'indexes': ['username', 'reputation'],
        'db_alias': globals.DB.ALIAS,
        'collection': globals.DB.USERS
    }
Exemplo n.º 27
0
class ActivityModel(AsloBaseModel):
    meta = {'collection': 'activity'}
    bundle_id = me.StringField(required=True, unique=True)
    name = me.DictField(required=True)
    summary = me.DictField(required=True)
    categories = me.ListField(me.StringField(max_length=30),
                              default=["unknown"])
    repository = me.StringField(required=True)
    license = me.StringField(required=True)
    icon = me.BinaryField(required=False, max_bytes=1000000)
    icon_hash = me.StringField(required=False)
    developers = me.EmbeddedDocumentListField(DeveloperModel, required=True)
    latest_release = me.ReferenceField(ReleaseModel)
    previous_releases = me.ListField(me.ReferenceField(ReleaseModel))
Exemplo n.º 28
0
class UserModel(mongoengine.Document):
    @classmethod
    def pre_save(cls, sender, document, **kwargs):
        globals.add_to_embeddings(username=document.user_name,
                                  encoding=pickle.loads(document.encoding))

    user_name = mongoengine.StringField(required=True)
    full_name = mongoengine.StringField(required=True)
    points = mongoengine.IntField(default=0, required=True)
    img = mongoengine.FileField(required=True)
    encoding = mongoengine.BinaryField(required=True)
    email = mongoengine.StringField(required=True)
    description = mongoengine.StringField(required=True)
    meta = {'db_alias': 'core', 'collection': 'users'}
Exemplo n.º 29
0
class web_vulns(mongoengine.Document):
    #__tablename__= "web_vulns"
    web_site_id = mongoengine.IntField(unique=True, null=False)
    path = mongoengine.StringField(null=False)
    method = mongoengine.StringField(null=False)
    params = mongoengine.StringField(null=False)
    pname = mongoengine.StringField(null=False)
    risk = mongoengine.IntField(null=False)
    name = mongoengine.StringField(null=False)
    query = mongoengine.StringField(null=False)
    category = mongoengine.StringField(null=False)
    confidence = mongoengine.IntField(null=False)
    description = mongoengine.StringField(null=False)
    blame = mongoengine.StringField(null=False)
    request = mongoengine.BinaryField()
    proof = mongoengine.BinaryField()
    owner = mongoengine.StringField(null=False)
    payload = mongoengine.StringField(null=False)
    created_at = mongoengine.DateTimeField(null=False)
    updated_at = mongoengine.DateTimeField(null=False)
    """meta= (Index('index_web_vulns_on_method','method'),
                      Index('index_web_vulns_on_name','name'),
                      Index('index_web_vulns_on_path','path'),)"""
    meta = {'indexes': [{'fields': ['method', 'name', 'path']}]}
Exemplo n.º 30
0
class BaseModel(mongoengine.Document):

    meta = {'allow_inheritance': True, 'indexes': ['user_id']}

    user_id = mongoengine.IntField()
    name = mongoengine.StringField(required=True)
    model_type = mongoengine.StringField(required=True)
    data = mongoengine.BinaryField()
    created_at = mongoengine.DateTimeField()
    updated_at = mongoengine.DateTimeField()

    def save(self, *args, **kwargs):
        if not self.created_at:
            self.created_at = datetime.datetime.now()
        self.updated_at = datetime.datetime.now()
        return super(BaseModel, self).save(*args, **kwargs)