Skip to content

Conversation

@StanBarrows
Copy link
Contributor

No description provided.

Copilot AI review requested due to automatic review settings August 1, 2025 16:21
@gitguardian
Copy link

gitguardian bot commented Aug 1, 2025

⚠️ GitGuardian has uncovered 2 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
19515427 Triggered Generic High Entropy Secret eef1a6d tests/Fixtures/Saloon/get-vaults.json View secret
19515428 Triggered Generic High Entropy Secret f3e6198 tests/Fixtures/Saloon/get-vaults.json View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@StanBarrows StanBarrows merged commit 499b715 into main Aug 1, 2025
13 of 14 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements the v12.0.3 feature update for the M-Files package, focusing on significant refactoring of authentication, caching mechanisms, and API integration patterns. The changes move from fixture-based testing to using real API responses through Saloon's MockResponse system and introduce a new caching layer for authentication tokens.

Key changes include:

  • Complete refactoring of authentication and caching mechanisms with new CacheKeyManager and updated authentication flow
  • Migration from custom fixtures to Saloon's MockResponse system with real API response data
  • Restructuring of DTOs and removal of deprecated classes like Documents, User, and DocumentProperties

Reviewed Changes

Copilot reviewed 72 out of 74 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/Unit/Helpers/CacheKeyManagerTest.php New unit tests for the cache key management functionality
tests/Unit/DTO/PropertyValueTest.php Comprehensive unit tests for PropertyValue DTO with all data types
tests/Fixtures/Saloon/*.json Updated test fixtures with real API responses replacing redacted test data
tests/Feature/Requests/*.php Refactored feature tests to use MockResponse instead of custom fixtures
src/Helpers/CacheKeyManager.php New cache management utility for authentication tokens
src/DTO/PropertyValue.php Simplified PropertyValue implementation with improved data type handling
src/DTO/ConfigWithCredentials.php Moved from Config subdirectory and simplified structure
src/Requests/*.php Updated request classes with simplified authentication and endpoint handling
src/Connectors/MFilesConnector.php Updated to use new authentication pattern with HeaderAuthenticator
Comments suppressed due to low confidence (1)

tests/Unit/DTO/PropertyValueTest.php:350

  • This test only verifies that properties can be accessed but doesn't actually test the readonly nature. Consider adding assertions that attempt to modify the properties and expect exceptions or use reflection to verify the readonly attribute.
    public function test_properties_are_readonly(): void

Comment on lines +17 to +22
public static function fromArray(int $propertyDef, MFDataTypeEnum $dataType, mixed $value): self
{
$typedValue = Arr::get($data, 'TypedValue', []);
$dataTypeId = Arr::get($typedValue, 'DataType', 0);
$dataType = MFDataTypeEnum::tryFrom($dataTypeId) ?? MFDataTypeEnum::UNINITIALIZED;

return new self(
propertyDef: Arr::get($data, 'PropertyDef'),
propertyDef: $propertyDef,
dataType: $dataType,
value: Arr::get($typedValue, 'Value'),
lookup: Arr::get($typedValue, 'Lookup'),
lookups: Arr::get($typedValue, 'Lookups'),
value: $value,
Copy link

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

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

The method signature suggests it creates from an array but actually takes individual parameters. Consider renaming to 'create' or 'make' to better reflect its purpose, or change the implementation to actually accept an array parameter.

Copilot uses AI. Check for mistakes.

$cacheManager = new CacheKeyManager($config);

return $cacheManager->rememberAuthToken(3600, function () use ($config) {
Copy link

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

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

The TTL value of 3600 seconds is hardcoded. Consider making this configurable through the config parameter or a class constant to improve maintainability.

Suggested change
return $cacheManager->rememberAuthToken(3600, function () use ($config) {
return $cacheManager->rememberAuthToken(self::DEFAULT_TTL, function () use ($config) {

Copilot uses AI. Check for mistakes.
/**
* Set authentication token in cache
*/
public function setAuthToken(mixed $token, int $ttl = 3600): bool
Copy link

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

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

The default TTL of 3600 seconds is hardcoded. Consider using a class constant or configuration value to make this more maintainable and consistent across the application.

Suggested change
public function setAuthToken(mixed $token, int $ttl = 3600): bool
public function setAuthToken(mixed $token, int $ttl = self::DEFAULT_TTL): bool

Copilot uses AI. Check for mistakes.
'Expiration' => $this->expiration,
];
$value = Arr::get($responseData, 'Value');
if (empty($value)) {
Copy link

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

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

Using empty() check may not be appropriate here as it would return true for '0' string or 0 integer, which could be valid token values. Consider using a more specific check like $value === null || $value === ''.

Suggested change
if (empty($value)) {
if ($value === null || $value === '') {

Copilot uses AI. Check for mistakes.
'username' => env('M_FILES_USERNAME'),
'password' => env('M_FILES_PASSWORD'),
'expiration' => env('M_FILES_EXPIRATION_SECONDS', '3600'), // Default to 1 hour
'expiration' => env('M_FILES_EXPIRATION_SECONDS', 1),
Copy link

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

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

The default expiration is set to 1 second, which is extremely short and likely will cause authentication failures. This should probably be a reasonable default like 3600 seconds (1 hour).

Suggested change
'expiration' => env('M_FILES_EXPIRATION_SECONDS', 1),
'expiration' => env('M_FILES_EXPIRATION_SECONDS', 3600),

Copilot uses AI. Check for mistakes.
@StanBarrows StanBarrows deleted the feature-v-12-0-3 branch August 1, 2025 16:24
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.

2 participants