Skip to content

sanitize preview when handling secret parameters #1036

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ in development

Changed
~~~~~~~
* Re-introduced preview sanitization for secrets. #1005

Contributed by @fdrab

* Updated various dependencies (security). #1009, #1020

Contributed by @enykeev
Expand Down
13 changes: 12 additions & 1 deletion apps/st2-actions/actions-details.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import React from 'react';
import { PropTypes } from 'prop-types';
import { connect } from 'react-redux';
import store from './store';
import _ from 'lodash';

import api from '@stackstorm/module-api';
import notification from '@stackstorm/module-notification';
Expand Down Expand Up @@ -270,6 +271,16 @@ export default class ActionsDetails extends React.Component {
this.setState({ runPreview });
}

sanitizePreview(code) {
return _.mapValues(code, (value, key) => {
if (value && this.props.action.parameters[key] && this.props.action.parameters[key].secret) {
return '*'.repeat(value.length);
}

return value;
});
}

handleToggleExecution(id) {
this.setState({
executionsVisible: {
Expand Down Expand Up @@ -477,7 +488,7 @@ export default class ActionsDetails extends React.Component {
</Link>
) : null }
</DetailsToolbar>
{ this.state.runPreview && <Highlight key="preview" well data-test="action_code" code={this.state.runValue} /> }
{ this.state.runPreview && <Highlight key="preview" well data-test="action_code" code={this.sanitizePreview(this.state.runValue)} /> }
<DetailsPanel key="panel" data-test="action_parameters">
<DetailsPanelBody>
<form>
Expand Down