Skip to content

refactor how 'tsh scp' destinations are parsed#24441

Merged
capnspacehook merged 1 commit intomasterfrom
capnspacehook/sftp-dst-parse-refactor
Apr 19, 2023
Merged

refactor how 'tsh scp' destinations are parsed#24441
capnspacehook merged 1 commit intomasterfrom
capnspacehook/sftp-dst-parse-refactor

Conversation

@capnspacehook
Copy link
Copy Markdown
Contributor

@capnspacehook capnspacehook commented Apr 12, 2023

A complex regex was previously used to parse 'tsh scp' destinations, which was hard to understand and even harder to maintain for those not intimately familiar with regex, despite it being heavily commented. Instead parse destinations directly and add more test cases and a fuzz test to ensure parsing won't panic and the new parse function doesn't have any regressions.

Fixes #11021.

@github-actions github-actions Bot requested review from lxea and timothyb89 April 12, 2023 14:34
@capnspacehook capnspacehook force-pushed the capnspacehook/sftp-dst-parse-refactor branch from 7bd0f25 to b2daaeb Compare April 12, 2023 14:34
Comment thread lib/sshutils/sftp/parse.go
@capnspacehook capnspacehook force-pushed the capnspacehook/sftp-dst-parse-refactor branch from b2daaeb to f9a5592 Compare April 13, 2023 15:54
@capnspacehook
Copy link
Copy Markdown
Contributor Author

Friendly ping @lxea @timothyb89

Comment thread lib/sshutils/sftp/parse.go Outdated
Comment thread lib/sshutils/sftp/parse.go Outdated
Comment thread lib/sshutils/sftp/parse.go Outdated
@capnspacehook capnspacehook force-pushed the capnspacehook/sftp-dst-parse-refactor branch from f9a5592 to 1df5169 Compare April 17, 2023 22:25
@capnspacehook capnspacehook requested a review from r0mant April 17, 2023 22:26
@capnspacehook
Copy link
Copy Markdown
Contributor Author

capnspacehook commented Apr 19, 2023

Friendly ping @r0mant @lxea @timothyb89. I'd like to get this in soon so I start backporting SFTP fixes all at once.

Copy link
Copy Markdown
Contributor

@jentfoo jentfoo left a comment

Choose a reason for hiding this comment

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

I believe there are some errors in the parsing here. One advantage regex has is that it gives me control on positions, where looking for specific characters could result in indexes at any point. I believe there needs to be more context testing (ie is : contained within []) for this type of parsing to function correctly.

Comment thread lib/sshutils/sftp/parse.go
Comment thread lib/sshutils/sftp/parse.go
Comment thread lib/sshutils/sftp/parse.go
@capnspacehook capnspacehook force-pushed the capnspacehook/sftp-dst-parse-refactor branch from 1df5169 to cd1e012 Compare April 19, 2023 21:07
@capnspacehook capnspacehook force-pushed the capnspacehook/sftp-dst-parse-refactor branch from cd1e012 to 29294af Compare April 19, 2023 21:41
A complex regex was previously used to parse 'tsh scp'
destinations, which was hard to understand and even harder
to maintain for those not intimately familiar with regex,
despite it being heavily commented. Instead parse destinations
directly and add more test cases and a fuzz test to ensure
parsing won't panic and the new parse function doesn't
have any regressions.
@capnspacehook capnspacehook force-pushed the capnspacehook/sftp-dst-parse-refactor branch from 29294af to 1612af7 Compare April 19, 2023 22:03
@capnspacehook capnspacehook enabled auto-merge April 19, 2023 22:07
@capnspacehook capnspacehook added this pull request to the merge queue Apr 19, 2023
Merged via the queue into master with commit a76e411 Apr 19, 2023
@capnspacehook capnspacehook deleted the capnspacehook/sftp-dst-parse-refactor branch April 19, 2023 22:31
@public-teleport-github-review-bot
Copy link
Copy Markdown

@capnspacehook See the table below for backport results.

Branch Result
branch/v11 Failed
branch/v12 Create PR
branch/v13 Create PR

@capnspacehook capnspacehook mentioned this pull request Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tsh don't scp if file path contains colon

4 participants