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

Hide full source paths from the user. #6

Merged
merged 3 commits into from
Jan 28, 2025
Merged
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
8 changes: 7 additions & 1 deletion Trell.Engine/ClearScriptWrappers/EngineWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,19 @@ DocumentContextCallback contextCallback
var dir = settings.SearchPath;
if (sourceInfo is DocumentInfo docInfo && docInfo.Uri is Uri docUri) {
dir = Path.GetDirectoryName(docUri.AbsolutePath) ?? "";
// Relocate the parent's including directory underneath the
// root directory search path (the worker's src).
dir = Path.Join(root, dir);
}

var extensions = settings.FileNameExtensions.Split(";");

if (TryGetRootedPath(root, dir, specifier, out var path)
&& File.Exists(path) && extensions.Contains(Path.GetExtension(path))) {
var uri = new Uri(path);
// The paths we give to ClearScript appear to be at / so that
// we can hide the actual path from the user.
var pathUnderRoot = path.Substring(root.Length);
var uri = new Uri("file://" + pathUnderRoot, UriKind.Absolute);
var info = new DocumentInfo(uri) {
Category = category,
ContextCallback = contextCallback,
Expand Down
3 changes: 3 additions & 0 deletions Trell/IPC/Worker/TrellWorkerCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ SqliteConnector Connector(IStorageProvider storage, string path) {
}
workResult.Message = ex.Message;
workResult.Stacktrace = ex.StackTrace;
if (ex is ScriptEngineException scriptEx) {
workResult.ScriptError = scriptEx.ErrorDetails;
}
}

return workResult;
Expand Down
1 change: 1 addition & 0 deletions Trell/Protos/Work.proto
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ message WorkResult {
ResultCode code = 1;
string message = 2;
optional string stacktrace = 3;
optional string scriptError = 4;
}

// Execution constraints.
Expand Down
Loading