Skip to content
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
20 changes: 19 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,23 @@ 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) {
switch (this.props.action.parameters[key].type) {
case "object":
return `{${'*'.repeat(Math.max(0, JSON.stringify(value).length -2))}}`;
case "array":
return `[${'*'.repeat(Math.max(0, JSON.stringify(value).length -2))}]`;
default:
return '*'.repeat(value.length);
}
}

return value;
});
}

handleToggleExecution(id) {
this.setState({
executionsVisible: {
Expand Down Expand Up @@ -477,7 +495,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