Esempio n. 1
0
File: models.py Progetto: QLGu/hue
  def save(self, *args, **kwargs):
    """
    Override `save` to optionally mask out the query from being saved to the
    database. This is because if the beeswax database contains sensitive
    information like personally identifiable information, that information
    could be leaked into the Hue database and logfiles.
    """

    if global_redaction_engine.is_enabled():
      redacted_query = global_redaction_engine.redact(self.query)

      if self.query != redacted_query:
        self.query = redacted_query
        self.is_redacted = True

    super(QueryHistory, self).save(*args, **kwargs)
Esempio n. 2
0
 def _redact_query(self):
   """
   Optionally mask out the query from being saved to the database. This is because if the database contains sensitive
   information like personally identifiable information, that information could be leaked into the Hue database and
   logfiles.
   """
   if global_redaction_engine.is_enabled() and self.type == 'notebook':
     data_dict = self.data_dict
     snippets = data_dict.get('snippets', [])
     for snippet in snippets:
       if snippet['type'] in ('hive', 'impala'):  # TODO: Pull SQL types from canonical lookup
         redacted_statement_raw = global_redaction_engine.redact(snippet['statement_raw'])
         if snippet['statement_raw'] != redacted_statement_raw:
           snippet['statement_raw'] = redacted_statement_raw
           snippet['statement'] = global_redaction_engine.redact(snippet['statement'])
           snippet['is_redacted'] = True
     self.data = json.dumps(data_dict)
Esempio n. 3
0
File: models.py Progetto: QLGu/hue
  def create_empty(cls, app_name, owner, data):
    query_type = SavedQuery.TYPES_MAPPING[app_name]
    design = SavedQuery(owner=owner, type=query_type)
    design.name = SavedQuery.DEFAULT_NEW_DESIGN_NAME
    design.desc = ''

    if global_redaction_engine.is_enabled():
      design.data = global_redaction_engine.redact(data)
    else:
      design.data = data

    design.is_auto = True
    design.save()

    Document.objects.link(design, owner=design.owner, extra=design.type, name=design.name, description=design.desc)
    design.doc.get().add_to_history()

    return design
Esempio n. 4
0
    def save(self, *args, **kwargs):
        """
    Override `save` to optionally mask out the query from being saved to the database. This is because if the database
    contains sensitive information like personally identifiable information, that information could be leaked into the
    Hue database and logfiles.
    """
        if global_redaction_engine.is_enabled() and self.type == "notebook":
            data_dict = self.data_dict
            snippets = data_dict.get("snippets", [])
            for snippet in snippets:
                if snippet["type"] in ("hive", "impala"):  # TODO: Pull SQL types from canonical lookup
                    redacted_statement_raw = global_redaction_engine.redact(snippet["statement_raw"])
                    if snippet["statement_raw"] != redacted_statement_raw:
                        snippet["statement_raw"] = redacted_statement_raw
                        snippet["statement"] = global_redaction_engine.redact(snippet["statement"])
                        snippet["is_redacted"] = True
            self.data = json.dumps(data_dict)

        super(Document2, self).save(*args, **kwargs)
Esempio n. 5
0
    def create_empty(cls, app_name, owner, data):
        query_type = SavedQuery.TYPES_MAPPING[app_name]
        design = SavedQuery(owner=owner, type=query_type)
        design.name = SavedQuery.DEFAULT_NEW_DESIGN_NAME
        design.desc = ''

        if global_redaction_engine.is_enabled():
            design.data = global_redaction_engine.redact(data)
        else:
            design.data = data

        design.is_auto = True
        design.save()

        Document.objects.link(design,
                              owner=design.owner,
                              extra=design.type,
                              name=design.name,
                              description=design.desc)
        design.doc.get().add_to_history()

        return design
Esempio n. 6
0
    def save(self, *args, **kwargs):
        """
    Override `save` to optionally mask out the query from being saved to the
    database. This is because if the beeswax database contains sensitive
    information like personally identifiable information, that information
    could be leaked into the Hue database and logfiles.
    """

        if global_redaction_engine.is_enabled():
            data = json.loads(self.data)

            try:
                query = data['query']['query']
            except KeyError:
                pass
            else:
                redacted_query = global_redaction_engine.redact(query)

                if query != redacted_query:
                    data['query']['query'] = redacted_query
                    self.is_redacted = True
                    self.data = json.dumps(data)

        super(SavedQuery, self).save(*args, **kwargs)
Esempio n. 7
0
File: models.py Progetto: QLGu/hue
  def save(self, *args, **kwargs):
    """
    Override `save` to optionally mask out the query from being saved to the
    database. This is because if the beeswax database contains sensitive
    information like personally identifiable information, that information
    could be leaked into the Hue database and logfiles.
    """

    if global_redaction_engine.is_enabled():
      data = json.loads(self.data)

      try:
        query = data['query']['query']
      except KeyError:
        pass
      else:
        redacted_query = global_redaction_engine.redact(query)

        if query != redacted_query:
          data['query']['query'] = redacted_query
          self.is_redacted = True
          self.data = json.dumps(data)

    super(SavedQuery, self).save(*args, **kwargs)