Skip to content

Commit d2d2321

Browse files
committed
sanitize preview when handling secret parameters
1 parent be6b339 commit d2d2321

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

apps/st2-actions/actions-details.component.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import React from 'react';
1717
import { PropTypes } from 'prop-types';
1818
import { connect } from 'react-redux';
1919
import store from './store';
20+
import _ from 'lodash';
2021

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

274+
sanitizePreview(code) {
275+
return _.mapValues(code, (value, key) => {
276+
if (value && this.props.action.parameters[key] && this.props.action.parameters[key].secret) {
277+
return '*'.repeat(value.length);
278+
}
279+
280+
return value;
281+
});
282+
}
283+
273284
handleToggleExecution(id) {
274285
this.setState({
275286
executionsVisible: {
@@ -477,7 +488,7 @@ export default class ActionsDetails extends React.Component {
477488
</Link>
478489
) : null }
479490
</DetailsToolbar>
480-
{ this.state.runPreview && <Highlight key="preview" well data-test="action_code" code={this.state.runValue} /> }
491+
{ this.state.runPreview && <Highlight key="preview" well data-test="action_code" code={this.sanitizePreview(this.state.runValue)} /> }
481492
<DetailsPanel key="panel" data-test="action_parameters">
482493
<DetailsPanelBody>
483494
<form>

0 commit comments

Comments
 (0)