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

Issue #43: Control the contents of extra in error log. #44

Merged
merged 14 commits into from
Feb 24, 2025
Merged

Conversation

alexmerlin
Copy link
Member

No description provided.

@alexmerlin alexmerlin self-assigned this Feb 6, 2025
@alexmerlin alexmerlin marked this pull request as draft February 6, 2025 15:01
@alexmerlin alexmerlin linked an issue Feb 6, 2025 that may be closed by this pull request
@alexmerlin
Copy link
Member Author

Note

I will write tests after we agree on the final form of the features (and their behaviour) implemented in this PR.

Signed-off-by: alexmerlin <[email protected]>
composer.json Outdated
@@ -29,6 +29,7 @@
"php": "~8.2.0 || ~8.3.0 || ~8.4.0",
"dotkernel/dot-log": "^4.1.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ask for 5.0 ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

} elseif (is_string($value)) {
$lowerKey = strtolower($key);
if (
str_contains($lowerKey, 'password') ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how if we move this array-key into config ?
in a forbidden-string array
to allow the developer to define from the beginning what key to not save in log files

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arhimede After I tried to implement this, I still think that we need a better solution for this type of filtering.

For exact key search, developers must add to the forbidden-string array each sensitive data related field name (password, passwordConfirm, userPasswordCsrf, contactFormCsrf) manually - which is error prone, as they might create a new form and forget to add the new key(s) to the array.

For partial key search (anything that matches password, key, csrf, token etc.), large forms with many fields might become an overkill to detect all keys.
Take for example a large...r form, with 50 fields.
We need to check each form field name against the forbidden-string array (that can have maybe 20 items), that's 50x20=1000 checks.

With larger forms, to me it seems overkill just for logging an error.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree is overkill ...

Can we disable by default this logger key then and warn the developer that if he enable it , can be a lot of issues

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I managed to optimize it so I kept this feature.

- Documentation
- Tests

Signed-off-by: alexmerlin <[email protected]>
Signed-off-by: alexmerlin <[email protected]>
Signed-off-by: alexmerlin <[email protected]>
@alexmerlin
Copy link
Member Author

🤯 Fun fact:
Psalm 6.7.0 incorrectly forces adding the #[Override] attribute on methods, even on PHP 8.2 where this attribute does not even exist yet (it was introduced only in PHP 8.3).

Running Psalm on the latest version of Psalm:
https://github.com/dotkernel/dot-errorhandler/actions/runs/13416774869/job/37479424993

Running Psalm on version (6.6.2) before the faulty version of Psalm:
https://github.com/dotkernel/dot-errorhandler/actions/runs/13416889062/job/37479822925

@alexmerlin
Copy link
Member Author

alexmerlin commented Feb 19, 2025

Created issue at Psalm:
vimeo/psalm#11320

Copy link

codecov bot commented Feb 20, 2025

Codecov Report

Attention: Patch coverage is 97.86325% with 5 lines in your changes missing coverage. Please review.

Please upload report for BASE (4.1@c0dcf58). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/Extra/Processor/CookieProcessor.php 90.90% 1 Missing ⚠️
src/Extra/Processor/HeaderProcessor.php 93.75% 1 Missing ⚠️
src/Extra/Processor/RequestProcessor.php 94.11% 1 Missing ⚠️
src/Extra/Processor/ServerProcessor.php 96.66% 1 Missing ⚠️
src/LogErrorHandlerFactory.php 90.90% 1 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff           @@
##             4.1      #44   +/-   ##
======================================
  Coverage       ?   98.46%           
  Complexity     ?      117           
======================================
  Files          ?       20           
  Lines          ?      326           
  Branches       ?        0           
======================================
  Hits           ?      321           
  Misses         ?        5           
  Partials       ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: alexmerlin <[email protected]>
Signed-off-by: alexmerlin <[email protected]>
Signed-off-by: alexmerlin <[email protected]>
Signed-off-by: alexmerlin <[email protected]>
@alexmerlin alexmerlin marked this pull request as ready for review February 20, 2025 09:16
@alexmerlin alexmerlin requested a review from arhimede February 20, 2025 09:16
@alexmerlin
Copy link
Member Author

@MarioRadu @pinclau @Jurj-Bogdan If you have time for a review...

@arhimede
Copy link
Member

modify readme.md fiwl to follow this model
https://github.com/dotkernel/light

Package Name H1

description wich use the PSr-15 keyword

Documentation H2

Documentation is available at:

Badges H2 on top of badges lines

and do this in documentation first page too

@alexmerlin
Copy link
Member Author

@arhimede Added the requested items in the last commit.

@arhimede arhimede merged commit 84f8368 into 4.1 Feb 24, 2025
28 of 29 checks passed
@alexmerlin alexmerlin deleted the issue-43 branch February 24, 2025 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC]: Log different informations if is on production or staging
2 participants