Skip to content

Commit

Permalink
security: Drop stack trace from failure message (#729)
Browse files Browse the repository at this point in the history
  • Loading branch information
topher-lo authored Jan 11, 2025
1 parent 1c54517 commit 79e6d4a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
1 change: 1 addition & 0 deletions frontend/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference types="next/navigation-types/compat/navigation" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
4 changes: 0 additions & 4 deletions frontend/src/components/executions/event-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ export function WorkflowExecutionEventDetailView({
<AccordionContent>
<div className="my-4 flex flex-col space-y-8 px-4">
<CodeBlock title="Message">{event.failure.message}</CodeBlock>
<CodeBlock title="Stack Trace">
{event.failure.stack_trace}
</CodeBlock>
<JsonViewWithControls src={event.failure} />
</div>
</AccordionContent>
</AccordionItem>
Expand Down
19 changes: 12 additions & 7 deletions tracecat/executor/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

from pydantic import UUID4, BaseModel

from tracecat.config import TRACECAT__APP_ENV


class ExecutorSyncInput(BaseModel):
repository_id: UUID4
Expand Down Expand Up @@ -31,13 +33,16 @@ class ExecutorActionErrorInfo(BaseModel):
"""Line number where the error occurred."""

def __str__(self) -> str:
return (
f"{self.type}: {self.message}"
f"\n\n{'-' * 30}"
f"\nFile: {self.filename}"
f"\nFunction: {self.function}"
f"\nLine: {self.lineno}"
)
if TRACECAT__APP_ENV == "development":
return (
f"{self.type}: {self.message}"
f"\n\n{'-' * 30}"
f"\nFile: {self.filename}"
f"\nFunction: {self.function}"
f"\nLine: {self.lineno}"
)
else:
return f"{self.type}: {self.message}"

@staticmethod
def from_exc(e: Exception, action_name: str) -> ExecutorActionErrorInfo:
Expand Down
4 changes: 0 additions & 4 deletions tracecat/workflow/executions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,7 @@ def from_initiated_child_workflow(

class EventFailure(BaseModel):
message: str
stack_trace: str
cause: dict[str, Any] | None = None
application_failure_info: dict[str, Any] = Field(default_factory=dict)

@staticmethod
def from_history_event(
Expand All @@ -254,9 +252,7 @@ def from_history_event(

return EventFailure(
message=failure.message,
stack_trace=failure.stack_trace,
cause=MessageToDict(failure.cause) if failure.cause is not None else None,
application_failure_info=MessageToDict(failure.application_failure_info),
)


Expand Down

0 comments on commit 79e6d4a

Please sign in to comment.