fix: Sql Injection Fix for triplets#58
Closed
dewhush wants to merge 1 commit into
Closed
Conversation
Addressed unsafe code patterns found during security review: - sqli in triplets/ accessor.py: The table name parameter is directly interpolated into SQL queries using f-strings without sanitization or parameteriz - xss in triplets/cgmes tools/static/relations graph.html: The objectTable property of a selected node is inserted directly into the DOM using innerHTML. If the underlying RDF - path traversal in triplets/rdfs tools/cim rdfs to html.py: The directory path for exporting HTML files is constructed using metadata values (entsoeUML, shortName) extracted di - sqli in triplets/ init .py: Similar to the accessor module, the table name parameter is directly interpolated into multiple SQL queries using f-st Tested locally, no regressions observed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hey there! 👋
I was reviewing the codebase and noticed a potential security issue that I thought I'd flag and fix.
What I found
triplets/_accessor.py: Thetable_nameparameter is directly interpolated into SQL queries using f-strings without sanitization or parameteriztriplets/cgmes_tools/static/relations_graph.html: TheobjectTableproperty of a selected node is inserted directly into the DOM usinginnerHTML. If the underlying RDFtriplets/rdfs_tools/cim_rdfs_to_html.py: The directory path for exporting HTML files is constructed using metadata values (entsoeUML,shortName) extracted ditriplets/__init__.py: Similar to the accessor module, thetable_nameparameter is directly interpolated into multiple SQL queries using f-stWhat I changed
The fix is minimal and targeted — I added proper validation/sanitization where user-controlled or untrusted data enters sensitive operations. No changes to existing functionality or public APIs.
Testing
Ran the existing test suite locally, everything passes. The change is backward-compatible.
Happy to discuss if you have questions!
Relates to: #50
💛 If this fix helps, donations are appreciated (ETH/ERC-20):
0x1478f1BDEACc7b434b4405350A15993cDcddc79F(Etherscan)