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

improve no-restricted-path rule for win32 paths #47435

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

mshustov
Copy link
Contributor

@mshustov mshustov commented Oct 7, 2019

Summary

micromatch transforms all win32 paths to POSIX format internally. isSameFolderOrDescendent can be called with paths in either format. I added the transformation to POSIX format to our logic as well.

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

For maintainers

@mshustov mshustov added chore Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc Feature:New Platform release_note:skip Skip the PR/issue when compiling release notes v7.5.0 labels Oct 7, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-platform (Team:Platform)

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@mshustov mshustov added this to Code review in kibana-core [DEPRECATED] via automation Oct 7, 2019
@mshustov mshustov added the review label Oct 7, 2019
@mshustov mshustov requested review from a team and spalger October 7, 2019 16:05
@LeeDr
Copy link
Contributor

LeeDr commented Oct 7, 2019

I made some bogus changes to a couple of the files that failed on my related issue and tried to commit them but I still these no-restricted-paths issues;

LeeDr@LeeDr-XPS MINGW64 ~/git/kibana (restrry-no-restricted-path-win)
$ git commit -m "bogus commit test"
ERROR
      C:\Users\LeeDr\git\kibana\src\core\server\saved_objects\migrations\core\migration_context.ts
        27:33  error  Unexpected path "src/core/server/logging" imported in restricted zone  @kbn/eslint/no-restricted-paths

      C:\Users\LeeDr\git\kibana\src\core\server\saved_objects\migrations\core\migration_logger.ts
        20:24  error  Unexpected path "src/core/server/logging" imported in restricted zone  @kbn/eslint/no-restricted-paths
        34:1   error  Delete `⏎··⏎`                                                          prettier/prettier

      ✖ 3 problems (3 errors, 0 warnings)
        1 error and 0 warnings potentially fixable with the `--fix` option.

ERROR [eslint] errors
Pre-commit hook failed (add --no-verify to bypass)
  For eslint failures you can try running `node scripts/precommit_hook --fix`

@spalger spalger requested review from LeeDr and removed request for spalger October 7, 2019 23:18
@joshdover
Copy link
Member

@LeeDr that seems right to me? This rule is supposed to prevent you from importing from that path. Maybe I'm missing something though.

@LeeDr
Copy link
Contributor

LeeDr commented Oct 8, 2019

@joshdover Maybe that's the case. But that means we have existing files in Kibana that fail the rule. And if that's the case, it should only block me from committing if I change those files in my branch?

@joshdover
Copy link
Member

Oh I didn't see this is an import from within Core. I think we need to just change those imports to be relative rather than from the root.

@mshustov
Copy link
Contributor Author

@elasticmachine merge upstream

@mshustov
Copy link
Contributor Author

@joshdover isSameFolderOrDescendent should handle this. looks like my fix doesn't help much.
I will get back to the problem later

@mshustov mshustov added v7.6.0 WIP Work in progress and removed review v7.5.0 labels Oct 15, 2019
@mshustov mshustov moved this from Code review to In progress in kibana-core [DEPRECATED] Oct 15, 2019
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@mshustov mshustov moved this from In progress to Icebox in kibana-core [DEPRECATED] Nov 12, 2019
@mshustov mshustov added v7.7.0 and removed v7.6.0 labels Feb 4, 2020
@joshdover
Copy link
Member

joshdover commented Mar 16, 2020

I think we can close this based on the discussion to remove support for Windows development: #58069

@LeeDr
Copy link
Contributor

LeeDr commented Mar 16, 2020

@joshdover I don't think there's been a decision on removing support for Windows development yet? I'm not sure how we finalize that decision. There hasn't been any comments on it from external users.

@joshdover
Copy link
Member

@elasticmachine merge upstream

@elasticmachine elasticmachine requested a review from a team as a code owner March 23, 2020 15:02
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

* toPosixPath('a\\b\\c') // 'a/b/c'
*/
function toPosixPath(filePath) {
return filePath.replace(winPathSeparatorRegExp, '/');
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I generally find string.split('\\').join('/') easier to understand and it's technically more performant too.

@mshustov mshustov added v8.0.0 and removed v7.7.0 labels Mar 24, 2020
@lukeelmers lukeelmers removed the v8.0.0 label Feb 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Feature:New Platform release_note:skip Skip the PR/issue when compiling release notes Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc WIP Work in progress
Development

Successfully merging this pull request may close these issues.

None yet

7 participants