-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change how its decided whether to store or expose activity properties
- Loading branch information
Showing
19 changed files
with
100 additions
and
81 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
src/core/Elsa.Abstractions/Events/ValidatePropertyExposure.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Elsa.Services.Models; | ||
using MediatR; | ||
|
||
namespace Elsa.Events; | ||
|
||
public class ValidatePropertyExposure : INotification | ||
{ | ||
public IWorkflowBlueprint WorkflowBlueprint { get; } | ||
public string ActivityId { get; } | ||
public string PropertyName { get; } | ||
|
||
public ValidatePropertyExposure(IWorkflowBlueprint workflowBlueprint, string activityId, string propertyName) | ||
{ | ||
WorkflowBlueprint = workflowBlueprint; | ||
ActivityId = activityId; | ||
PropertyName = propertyName; | ||
} | ||
|
||
public bool CanExposeProperty { get; private set; } = true; | ||
public void PreventPropertyExposure() => CanExposeProperty = false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/modules/secrets/Elsa.Secrets/Handlers/ValidatePropertyStoringHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System.Text.RegularExpressions; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Elsa.Events; | ||
using Elsa.Secrets.Providers; | ||
using Elsa.Services.Workflows; | ||
using MediatR; | ||
|
||
namespace Elsa.Secrets.Handlers; | ||
|
||
public class ValidatePropertyExposureHandler : INotificationHandler<ValidatePropertyExposure> | ||
{ | ||
private readonly Regex _fullyQualifiedName = new Regex("(?<Type>[^:]+):(?<Name>.*)", RegexOptions.IgnoreCase | RegexOptions.Singleline); | ||
private readonly ISecretsProvider _secretsProvider; | ||
|
||
public ValidatePropertyExposureHandler(ISecretsProvider secretsProvider) | ||
{ | ||
_secretsProvider = secretsProvider; | ||
} | ||
|
||
public async Task Handle(ValidatePropertyExposure notification, CancellationToken cancellationToken) | ||
{ | ||
var propProvider = notification.WorkflowBlueprint.ActivityPropertyProviders.GetProvider(notification.ActivityId, notification.PropertyName); | ||
var expressionProvider = propProvider as ExpressionActivityPropertyValueProvider; | ||
|
||
if (expressionProvider is not { Syntax: "Secret" }) | ||
{ | ||
return; | ||
} | ||
|
||
Match m; | ||
if ((m = _fullyQualifiedName.Match(expressionProvider.Expression)).Success) | ||
{ | ||
if (await _secretsProvider.IsSecretValueSensitiveData(m.Groups["Type"].Value, m.Groups["Name"].Value)) | ||
{ | ||
notification.PreventPropertyExposure(); | ||
} | ||
} | ||
else | ||
{ | ||
if (await _secretsProvider.IsSecretValueSensitiveData(expressionProvider.Expression)) | ||
{ | ||
notification.PreventPropertyExposure(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters