提交 8cf29eb7 编写于 作者: L Liangliang He

Force jinja escape quoted string to prevent security issues when using third party models

上级 5a0a017c
...@@ -64,7 +64,8 @@ namespace {{tag}} { ...@@ -64,7 +64,8 @@ namespace {{tag}} {
{% for i in range(start, end) %} {% for i in range(start, end) %}
void CreateOperator{{i}}(mace::OperatorDef *op) { void CreateOperator{{i}}(mace::OperatorDef *op) {
MACE_LATENCY_LOGGER(2, "Create operator {{ net.op[i].name }}"); MACE_LATENCY_LOGGER(2, "Create operator",
{{ net.op[i].name|default("undefined")|tojson }});
mace::Argument *arg = nullptr; mace::Argument *arg = nullptr;
op->mutable_arg()->Reserve({{ net.op[i].arg|length }}); op->mutable_arg()->Reserve({{ net.op[i].arg|length }});
......
...@@ -25,10 +25,10 @@ namespace {{tag}} { ...@@ -25,10 +25,10 @@ namespace {{tag}} {
const std::map<std::string, ClProgramInfo> {{variable_name}} = { const std::map<std::string, ClProgramInfo> {{variable_name}} = {
{% for key, encrypted_code in maps.items() %} {% for key, encrypted_code in maps.items() %}
{ {
"{{key}}", { {{key|tojson}}, {
{ {
{%- for header in encrypted_code['headers'] -%} {%- for header in encrypted_code['headers'] -%}
"{{header}}", {{header|tojson}},
{%- endfor -%} {%- endfor -%}
}, },
{ {
......
...@@ -134,7 +134,7 @@ void CreateTensors(NetDef *net_def) { ...@@ -134,7 +134,7 @@ void CreateTensors(NetDef *net_def) {
namespace {{tag}} { namespace {{tag}} {
MACE_API const std::shared_ptr<NetDef> CreateNet() { MACE_API const std::shared_ptr<NetDef> CreateNet() {
MACE_LATENCY_LOGGER(1, "Create net {{ net.name }}"); MACE_LATENCY_LOGGER(1, "Create net ", {{ net.name|default("undefined")|tojson }});
std::shared_ptr<NetDef> net_def(new NetDef()); std::shared_ptr<NetDef> net_def(new NetDef());
......
...@@ -64,7 +64,8 @@ namespace {{tag}} { ...@@ -64,7 +64,8 @@ namespace {{tag}} {
{% for i in range(start, end) %} {% for i in range(start, end) %}
void CreateOperator{{i}}(mace::OperatorDef *op) { void CreateOperator{{i}}(mace::OperatorDef *op) {
MACE_LATENCY_LOGGER(2, "Create operator {{ net.op[i].name }}"); MACE_LATENCY_LOGGER(2, "Create operator ",
{{ net.op[i].name|default("undefined")|tojson }});
mace::Argument *arg = nullptr; mace::Argument *arg = nullptr;
op->mutable_arg()->Reserve({{ net.op[i].arg|length }}); op->mutable_arg()->Reserve({{ net.op[i].arg|length }});
......
...@@ -23,7 +23,8 @@ namespace mace { ...@@ -23,7 +23,8 @@ namespace mace {
namespace {{tag}} { namespace {{tag}} {
void CreateTensor{{tensor_id}}(mace::ConstTensor *const_tensor) { void CreateTensor{{tensor_id}}(mace::ConstTensor *const_tensor) {
MACE_LATENCY_LOGGER(2, "Create tensor {{ tensor.name }}"); MACE_LATENCY_LOGGER(2, "Create tensor ",
{{ tensor.name|default("undefined")|tojson }});
const_tensor->set_name({{ tensor.name|tojson }}); const_tensor->set_name({{ tensor.name|tojson }});
const_tensor->set_offset({{ tensor.offset }}); const_tensor->set_offset({{ tensor.offset }});
const_tensor->set_data_size({{ tensor.data_size }}); const_tensor->set_data_size({{ tensor.data_size }});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册