core.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:incubator-airflow-old 作者: apache 项目源码 文件源码
def test_chart_data_template(self):
        """Protect chart_data from being able to do RCE."""
        session = settings.Session()
        Chart = models.Chart
        chart1 = Chart(
            label='insecure_chart',
            conn_id='airflow_db',
            chart_type='bar',
            sql="SELECT {{ ''.__class__.__mro__[1].__subclasses__() }}"
        )
        chart2 = Chart(
            label="{{ ''.__class__.__mro__[1].__subclasses__() }}",
            conn_id='airflow_db',
            chart_type='bar',
            sql="SELECT 1"
        )
        chart3 = Chart(
            label="{{ subprocess.check_output('ls') }}",
            conn_id='airflow_db',
            chart_type='bar',
            sql="SELECT 1"
        )
        session.add(chart1)
        session.add(chart2)
        session.add(chart3)
        session.commit()
        chart1_id = session.query(Chart).filter(Chart.label=='insecure_chart').first().id
        with self.assertRaises(SecurityError):
            response = self.app.get("/admin/airflow/chart_data?chart_id={}".format(chart1_id))
        chart2_id = session.query(Chart).filter(Chart.label=="{{ ''.__class__.__mro__[1].__subclasses__() }}").first().id
        with self.assertRaises(SecurityError):
            response = self.app.get("/admin/airflow/chart_data?chart_id={}".format(chart2_id))
        chart3_id = session.query(Chart).filter(Chart.label=="{{ subprocess.check_output('ls') }}").first().id
        with self.assertRaises(UndefinedError):
            response = self.app.get("/admin/airflow/chart_data?chart_id={}".format(chart3_id))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号