Ejemplo n.º 1
0
    def _redact(self):
        from airflow.utils.log.secrets_masker import redact

        if self.k8s_pod_yaml:
            self.k8s_pod_yaml = redact(self.k8s_pod_yaml)

        for field, rendered in self.rendered_fields.items():
            self.rendered_fields[field] = redact(rendered, field)
Ejemplo n.º 2
0
    def serialize_extra(obj: Connection):
        if obj.extra is None:
            return
        from airflow.utils.log.secrets_masker import redact

        try:
            extra = json.loads(obj.extra)
            return json.dumps(redact(extra))
        except json.JSONDecodeError:
            # we can't redact fields in an unstructured `extra`
            return obj.extra
Ejemplo n.º 3
0
    def get_connection(cls, conn_id: str) -> "Connection":
        """
        Get connection, given connection id.

        :param conn_id: connection id
        :return: connection
        """
        from airflow.models.connection import Connection

        conn = Connection.get_connection_from_secrets(conn_id)
        log.info("Using connection ID '%s' for task execution.", conn.conn_id)
        log.debug(
            "Connection details for '%s':: Host: %s, Port: %s, Schema: %s, Login: %s, Password: %s, "
            "Extra: %s",
            conn.conn_id,
            conn.host,
            conn.port,
            conn.schema,
            conn.login,
            redact(conn.password),
            redact(conn.extra_dejson),
        )
        return conn
Ejemplo n.º 4
0
    def get_connection(cls, conn_id: str) -> "Connection":
        """
        Get connection, given connection id.

        :param conn_id: connection id
        :return: connection
        """
        from airflow.models.connection import Connection

        conn = Connection.get_connection_from_secrets(conn_id)
        if conn.host:
            log.info(
                "Using connection to: id: %s. Host: %s, Port: %s, Schema: %s, Login: %s, Password: %s, "
                "extra: %s",
                conn.conn_id,
                conn.host,
                conn.port,
                conn.schema,
                conn.login,
                redact(conn.password),
                redact(conn.extra_dejson),
            )
        return conn