1
1
mirror of https://github.com/pterodactyl/panel.git synced 2024-11-25 10:32:31 +01:00

Hide IP addresses from activity logs not generated by the user themselves

This commit is contained in:
DaneEveritt 2022-06-27 20:52:27 -04:00
parent b570769a34
commit 4aa163b76f
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
5 changed files with 15 additions and 18 deletions

View File

@ -16,10 +16,7 @@ class ActivityLogController extends ClientApiController
{
$activity = QueryBuilder::for($request->user()->activity())
->with('actor')
->allowedFilters([
AllowedFilter::exact('ip'),
AllowedFilter::partial('event'),
])
->allowedFilters([AllowedFilter::partial('event')])
->allowedSorts(['timestamp'])
->paginate(min($request->query('per_page', 25), 100))
->appends($request->query());

View File

@ -25,10 +25,7 @@ class ActivityLogController extends ClientApiController
$activity = QueryBuilder::for($server->activity())
->with('actor')
->allowedSorts(['timestamp'])
->allowedFilters([
AllowedFilter::exact('ip'),
AllowedFilter::partial('event'),
])
->allowedFilters([AllowedFilter::partial('event')])
->when(config('activity.hide_admin_activity'), function (Builder $builder) use ($server) {
// We could do this with a query and a lot of joins, but that gets pretty
// painful so for now we'll execute a simpler query.

View File

@ -21,7 +21,7 @@ class ActivityLogTransformer extends BaseClientTransformer
'batch' => $model->batch,
'event' => $model->event,
'is_api' => !is_null($model->api_key_id),
'ip' => $model->ip,
'ip' => optional($model->actor)->is($this->request->user()) ? $model->ip : null,
'description' => $model->description,
'properties' => $this->properties($model),
'has_additional_metadata' => $this->hasAdditionalMetadata($model),
@ -49,7 +49,11 @@ class ActivityLogTransformer extends BaseClientTransformer
}
$properties = $model->properties
->mapWithKeys(function ($value, $key) {
->mapWithKeys(function ($value, $key) use ($model) {
if ($key === 'ip' && !optional($model->actor)->is($this->request->user())) {
return [$key => '[hidden]'];
}
if (!is_array($value)) {
return [$key => $value];
}

View File

@ -22,7 +22,7 @@ interface SSHKey extends Model {
interface ActivityLog extends Model<'actor'> {
batch: UUID | null;
event: string;
ip: string;
ip: string | null;
isApi: boolean;
description: string | null;
properties: Record<string, string | unknown>;

View File

@ -75,13 +75,12 @@ export default ({ activity, children }: Props) => {
<Translate ns={'activity'} values={properties} i18nKey={activity.event.replace(':', '.')} />
</p>
<div className={'mt-1 flex items-center text-sm'}>
<Link
to={`#${pathTo({ ip: activity.ip })}`}
className={'transition-colors duration-75 active:text-cyan-400 hover:text-cyan-400'}
>
{activity.ip}
</Link>
<span className={'text-gray-400'}>&nbsp;|&nbsp;</span>
{activity.ip && (
<span>
{activity.ip}
<span className={'text-gray-400'}>&nbsp;|&nbsp;</span>
</span>
)}
<Tooltip placement={'right'} content={format(activity.timestamp, 'MMM do, yyyy H:mm:ss')}>
<span>{formatDistanceToNowStrict(activity.timestamp, { addSuffix: true })}</span>
</Tooltip>