Skip to content

Hardening suggestions for codemodder-python / sqlp-formatop#362

Merged
andrecsilva merged 1 commit intosqlp-formatopfrom
pixeebot/sqlp-formatop
Mar 12, 2024
Merged

Hardening suggestions for codemodder-python / sqlp-formatop#362
andrecsilva merged 1 commit intosqlp-formatopfrom
pixeebot/sqlp-formatop

Conversation

@pixeebot
Copy link
Copy Markdown
Contributor

@pixeebot pixeebot bot commented Mar 12, 2024

I've reviewed the recently opened PR (361 - Adds support for format operators in SQLQueryParameterization) and have identified some area(s) that could benefit from additional hardening measures.

These changes should help prevent potential security vulnerabilities and improve overall code quality.

Thank you for your consideration!

docs | feedback
Powered by: pixeebot

@pixeebot pixeebot bot requested a review from andrecsilva March 12, 2024 14:01
@pixeebot pixeebot bot requested a review from clavedeluna as a code owner March 12, 2024 14:01
case cst.Name():
target_acesses = self.find_accesses(node)
if target_acesses:
if target_acesses := self.find_accesses(node):
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaces multiple expressions involving if operator with 'walrus' operator.

new_target = self._handle_target(target.target)
if new_target:
if new_target := self._handle_target(target.target):
new_targets.append(target.with_changes(target=new_target))
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaces multiple expressions involving if operator with 'walrus' operator.

match piece:
case cst.SimpleString() | cst.FormattedStringText():
maybe_conversion = _convert_piece_and_parts(
if maybe_conversion := _convert_piece_and_parts(
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaces multiple expressions involving if operator with 'walrus' operator.

raw_value = extract_raw_value(node)
prefix = self.extract_prefix(node)
if prefix is not None:
if (prefix := self.extract_prefix(node)) is not None:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaces multiple expressions involving if operator with 'walrus' operator.

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Passed Quality Gate passed

Issues
1 New issue
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@andrecsilva andrecsilva merged commit 2055b6d into sqlp-formatop Mar 12, 2024
@andrecsilva andrecsilva deleted the pixeebot/sqlp-formatop branch March 12, 2024 14:07
andrecsilva pushed a commit that referenced this pull request Mar 13, 2024
Use Assignment Expression (Walrus) In Conditional

Co-authored-by: pixeebot[bot] <104101892+pixeebot[bot]@users.noreply.github.com>
andrecsilva pushed a commit that referenced this pull request Mar 14, 2024
Use Assignment Expression (Walrus) In Conditional

Co-authored-by: pixeebot[bot] <104101892+pixeebot[bot]@users.noreply.github.com>
github-merge-queue bot pushed a commit that referenced this pull request Mar 14, 2024
* Format expressions initial implementation

* Format expressions initial implementation

* Transform to remove empty string formatting

* Refactoring and documentation

* Refactoring and documentation

* Tests for printf style string parser

* LinearizeStringExpression tests

* Tests for SQL parameterization with printf format strings

* Refactored and moved cleaning transformations

* Refactoring and more tests

* Linting

* fixup! Refactoring and more tests

* Hardening suggestions for codemodder-python / sqlp-formatop (#362)

Use Assignment Expression (Walrus) In Conditional

Co-authored-by: pixeebot[bot] <104101892+pixeebot[bot]@users.noreply.github.com>

* fixup! Hardening suggestions for codemodder-python / sqlp-formatop (#362)

* Small refactoring

* fixup! Small refactoring

* Better documentation

* Disables RemoveUnnecessarFStr and test

---------

Co-authored-by: pixeebot[bot] <104101892+pixeebot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant