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

Strip ansi color codes and do not use bypass HTML function #5737

Merged
merged 1 commit into from
Jan 7, 2021

Conversation

floreks
Copy link
Member

@floreks floreks commented Dec 21, 2020

  • Applied npm audit fix
  • Slight refactoring of log component
  • Removed ansi-to-html and added strip-ansi instead
  • Removed usage of bypassSecurityTrustHtml
  • Fixed potential issue with not escaping some of the HTML codes properly. Replace was not done globally and in some cases, it was possible to display i.e. a clickable link inside logs.

Since every log line was first sanitized before applying ANSI to HTML conversion, I do not think there was a potential XSS vulnerability. The converter itself would have to be compromised in order to append insecure code. In order to prevent that logs will be further stripped from ANSI codes.

Example

Zrzut ekranu z 2020-12-21 13-27-11
Zrzut ekranu z 2020-12-21 13-27-33

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Dec 21, 2020
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 21, 2020
@codecov
Copy link

codecov bot commented Dec 21, 2020

Codecov Report

Merging #5737 (97bc9ad) into master (7cfdb00) will increase coverage by 0.04%.
The diff coverage is 42.85%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5737      +/-   ##
==========================================
+ Coverage   44.34%   44.38%   +0.04%     
==========================================
  Files         214      214              
  Lines        9126     9117       -9     
  Branches      113      112       -1     
==========================================
  Hits         4047     4047              
+ Misses       4804     4796       -8     
+ Partials      275      274       -1     
Impacted Files Coverage Δ
src/app/frontend/common/pipes/safehtml.ts 58.33% <42.85%> (+15.47%) ⬆️
src/app/frontend/login/component.ts 76.74% <0.00%> (+1.16%) ⬆️
...p/backend/integration/metric/common/aggregation.go 90.00% <0.00%> (+2.00%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7cfdb00...97bc9ad. Read the comment docs.

@maciaszczykm
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 21, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: floreks, maciaszczykm

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

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [floreks,maciaszczykm]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubernetes kubernetes deleted a comment from floreks Dec 21, 2020
@maciaszczykm maciaszczykm merged commit 5cf991c into kubernetes:master Jan 7, 2021
@maciaszczykm maciaszczykm deleted the fix/ansi-color branch January 7, 2021 08:22
@MichaelJCole
Copy link

Hurray! Thanks! Go Team!

@MattJeanes
Copy link

Does this change mean that colours are no longer supported in the logs view?

@floreks
Copy link
Member Author

floreks commented Apr 8, 2021

@MattJeanes correct. They are stripped from the logs to not impact readability.

@MattJeanes
Copy link

A shame, but understandable given the security concern - thanks for letting me know, not sure if that would be worth a mention in the v2.2.0 release notes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants