Skip to content
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

optimize: validate that the primary key is free of illegal characters #6227

Merged
merged 4 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/en-us/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Add changes here for all PR submitted to the 2.x branch.
- [[#6200](https://github.com/apache/incubator-seata/pull/6200)] cancel required_status_checks
- [[#6201](https://github.com/apache/incubator-seata/pull/6201)] restore required_status_checks kept to remove context validation
- [[#6218](https://github.com/apache/incubator-seata/pull/6218)] remove Seata-Docker link
- [[#6227](https://github.com/apache/incubator-seata/pull/6227)] validate that the primary key is free of illegal characters

### security:
- [[#6069](https://github.com/apache/incubator-seata/pull/6069)] Upgrade Guava dependencies to fix security vulnerabilities
Expand Down
1 change: 1 addition & 0 deletions changes/zh-cn/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
- [[#6200](https://github.com/apache/incubator-seata/pull/6200)] 去除required_status_checks检查
- [[#6201](https://github.com/apache/incubator-seata/pull/6201)] 恢复required_status_checks但去除context校验
- [[#6218](https://github.com/apache/incubator-seata/pull/6218)] 移除Seata-Docker链接
- [[#6227](https://github.com/apache/incubator-seata/pull/6227)] 校验pk中不含逗号

### security:
- [[#6069](https://github.com/apache/incubator-seata/pull/6069)] 升级Guava依赖版本,修复安全漏洞
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,17 @@ protected void prepareUndoLog(TableRecords beforeImage, TableRecords afterImage)
}
}

/**
* validate that the primary key is free of illegal characters
*
* @param pkVal primary key value
*/
protected void validPk(String pkVal) {
if (pkVal.contains(",")) {
throw new IllegalArgumentException(pkVal + " contains illegal character!");
}
}

/**
* build lockKey
*
Expand All @@ -421,7 +432,6 @@ protected String buildLockKey(TableRecords rowsIncludingPK) {
if (rowsIncludingPK.size() == 0) {
return null;
}

StringBuilder sb = new StringBuilder();
sb.append(rowsIncludingPK.getTableMeta().getTableName());
sb.append(":");
Expand All @@ -434,7 +444,9 @@ protected String buildLockKey(TableRecords rowsIncludingPK) {
if (pkSplitIndex > 0) {
sb.append("_");
}
sb.append(rowMap.get(pkName).getValue());
Object pkVal = rowMap.get(pkName).getValue();
validPk(String.valueOf(pkVal));
sb.append(pkVal);
pkSplitIndex++;
}
rowSequence++;
Expand Down
Loading