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

security(cdc): fix some security problems #3700

Merged
merged 8 commits into from
Dec 6, 2021
Merged

security(cdc): fix some security problems #3700

merged 8 commits into from
Dec 6, 2021

Conversation

Ehco1996
Copy link
Contributor

@Ehco1996 Ehco1996 commented Dec 2, 2021

What problem does this PR solve?

fix https://github.com/pingcap/ticdc/issues/3696

preview the fixed results here

What is changed and how it works?

Check List

Tests

  • Unit test
  • Integration test

Code changes

Side effects

Related changes

Release note

 `None`.

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Dec 2, 2021

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • asddongmen
  • okJiang

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 2, 2021
@Ehco1996
Copy link
Contributor Author

Ehco1996 commented Dec 2, 2021

/run-all-tests

@Ehco1996
Copy link
Contributor Author

Ehco1996 commented Dec 2, 2021

/run-integration-test
/run-kafka-integration-test

@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 3, 2021
@codecov-commenter
Copy link

codecov-commenter commented Dec 3, 2021

Codecov Report

Merging #3700 (a142ea3) into master (7702989) will increase coverage by 0.5424%.
The diff coverage is 80.0630%.

Flag Coverage Δ
cdc 58.7564% <80.1105%> (+1.1368%) ⬆️
dm 56.3627% <50.0000%> (-0.0023%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

@@               Coverage Diff                @@
##             master      #3700        +/-   ##
================================================
+ Coverage   56.9451%   57.4876%   +0.5424%     
================================================
  Files           455        460         +5     
  Lines         54110      54824       +714     
================================================
+ Hits          30813      31517       +704     
+ Misses        20085      20041        -44     
- Partials       3212       3266        +54     

@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 3, 2021
@Ehco1996
Copy link
Contributor Author

Ehco1996 commented Dec 3, 2021

/run-all-tests

@Ehco1996
Copy link
Contributor Author

Ehco1996 commented Dec 3, 2021

/run-integration-test

@Ehco1996 Ehco1996 added the area/ticdc Issues or PRs related to TiCDC. label Dec 3, 2021
@Ehco1996 Ehco1996 marked this pull request as ready for review December 3, 2021 05:53
@ti-chi-bot ti-chi-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 3, 2021
@Ehco1996
Copy link
Contributor Author

Ehco1996 commented Dec 3, 2021

could you please take another look for this pr ? thanks 🧡🧡🧡 @hi-rustin @asddongmen

@Ehco1996 Ehco1996 added the status/ptal Could you please take a look? label Dec 3, 2021
@@ -72,7 +72,7 @@ func (c *Config) CompleteByOpts(sinkURI *url.URL, replicaConfig *config.ReplicaC
params := sinkURI.Query()
s := params.Get("partition-num")
if s != "" {
a, err := strconv.Atoi(s)
Copy link
Contributor

Choose a reason for hiding this comment

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

why this is a security problem 😂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

becasue in L79 c.PartitionNum = int32(a) try convert int to int32 😂

var line dataRow
row := db.QueryRow(query)
row := db.QueryRow(query, tableName)
Copy link
Member

Choose a reason for hiding this comment

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

What's the difference in this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the old one may casue sql jnjection see more here

Copy link
Member

Choose a reason for hiding this comment

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

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Dec 3, 2021
Copy link
Member

@Rustin170506 Rustin170506 left a comment

Choose a reason for hiding this comment

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

rest LGTM

@@ -65,7 +65,7 @@ func newFileBackEnd(fileName string, serde encoding.SerializerDeserializer) (*fi
}

func (f *fileBackEnd) reader() (backEndReader, error) {
fd, err := os.OpenFile(f.fileName, os.O_RDWR, 0o644)
fd, err := os.OpenFile(f.fileName, os.O_RDWR, 0o600)
Copy link
Member

Choose a reason for hiding this comment

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

/cc @liuzix

Could you please take a look? Thanks! 💚 💙 💜 💛 ❤️

@ti-chi-bot ti-chi-bot requested a review from liuzix December 3, 2021 13:52
@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 4, 2021
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 6, 2021
@asddongmen asddongmen self-requested a review December 6, 2021 03:02
@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Dec 6, 2021
@asddongmen
Copy link
Contributor

/run-integration-tests

@amyangfei
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: a142ea3

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Dec 6, 2021
@Ehco1996
Copy link
Contributor Author

Ehco1996 commented Dec 6, 2021

/run-dm-integration-tests

@ti-chi-bot ti-chi-bot merged commit eed6f9b into pingcap:master Dec 6, 2021
okJiang pushed a commit to okJiang/tiflow that referenced this pull request Dec 8, 2021
@Ehco1996 Ehco1996 deleted the cdc-gosec branch December 20, 2021 01:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ticdc Issues or PRs related to TiCDC. release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. status/ptal Could you please take a look?
Projects
None yet
Development

Successfully merging this pull request may close these issues.

make cdc pass verifyCI with gosec
8 participants