-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Constant attr to visitor #3540
Constant attr to visitor #3540
Conversation
6f35598
to
81f4850
Compare
81f4850
to
22a2cf9
Compare
inference-engine/tests/ie_test_utils/common_test_utils/ngraph_test_utils.cpp
Outdated
Show resolved
Hide resolved
inference-engine/tests/functional/inference_engine/ir_serialization/serialize.cpp
Outdated
Show resolved
Hide resolved
inference-engine/tests/functional/inference_engine/ir_serialization/serialize.cpp
Outdated
Show resolved
Hide resolved
inference-engine/tests/functional/inference_engine/ir_serialization/serialize.cpp
Outdated
Show resolved
Hide resolved
inference-engine/tests/functional/inference_engine/ir_serialization/serialize.cpp
Outdated
Show resolved
Hide resolved
inference-engine/src/transformations/src/transformations/serialize.cpp
Outdated
Show resolved
Hide resolved
inference-engine/src/transformations/src/transformations/serialize.cpp
Outdated
Show resolved
Hide resolved
inference-engine/src/transformations/src/transformations/serialize.cpp
Outdated
Show resolved
Hide resolved
inference-engine/tests/ie_test_utils/common_test_utils/test_common.hpp
Outdated
Show resolved
Hide resolved
inference-engine/src/transformations/src/transformations/serialize.cpp
Outdated
Show resolved
Hide resolved
|
||
// Return false because we didn't change nGraph Function | ||
return false; | ||
} | ||
|
||
namespace { | ||
std::string bestBinPath(const std::string &xmlPath, const std::string &binPath) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pelszkow please explain why you need this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because some e2e tests are failing. Some test pass empty path here.
void serialize(const std::string& xmlPath, const std::string& binPath = "") const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I propose that we need to create the bin
file with the same name as xml
file if bin
path is empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. So current approach is OK - .xml is replaced with .bin.
There is one issue though, we don't check that xml path is valid, and malicious user can pass shorter than 3 character string and we will have out of bounds access.
I would do what follows:
if (xml_path is not valid path (non-empty + alphanumeric characters only?) )
throw
else if (xml_path ends with .xml)
bin_path = xml_path with replaced .xml with .bin
else
bin_name = xml_path + ".bin"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should have the next logic:
if (bin_path is empty) {
if (xml_path is not valid path (non-empty + alphanumeric characters only?) )
throw
else if (xml_path ends with .xml)
bin_path = xml_path with replaced .xml with .bin
else
// Looks like if xml_path doesn't have .xml as an extension it is not valid path
throw
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have just realize that we are discuss about filename
validation and not about whole path (with filename). /
or c:\
are not alnum only.
When I add this validation I get error:
[ ERROR ] Can't get executable graph: Check 'std::all_of(begin(path), end(path), [](char c) { return std::isalnum(c); })' failed at ../inference-engine/src/transformations/src/transformations/serialize.cpp:517:
Filename for xml file contains invalid characters (alnum valid only): "/mnt/data/workspace/openvino/openvino/build/install/deployment_tools/exec_graph.xml"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pelszkow Did you fix the issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I drop isalnum
path validation idea. Without this validation (is not present in master) all works fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IE test part LGTM
|
||
// Return false because we didn't change nGraph Function | ||
return false; | ||
} | ||
|
||
namespace { | ||
std::string bestBinPath(const std::string &xmlPath, const std::string &binPath) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. So current approach is OK - .xml is replaced with .bin.
There is one issue though, we don't check that xml path is valid, and malicious user can pass shorter than 3 character string and we will have out of bounds access.
I would do what follows:
if (xml_path is not valid path (non-empty + alphanumeric characters only?) )
throw
else if (xml_path ends with .xml)
bin_path = xml_path with replaced .xml with .bin
else
bin_name = xml_path + ".bin"
* Add new path for constant in IR serializer. * Apply suggestion from review. * Unique name for temporary test file * Switch from static to constant member function - GetTestName * Ensure bin path is not empty. * Compare Constants op by string values converted to float. * Add path validation. Co-authored-by: Patryk Elszkowski <[email protected]>
Ticket: 40740