open-telemetry / opentelemetry-php

The OpenTelemetry PHP Library
https://opentelemetry.io/docs/instrumentation/php/
Apache License 2.0
752 stars 186 forks source link

guard against possible false value from file_get_contents in Host.php #1430

Closed jspaetzel closed 1 week ago

jspaetzel commented 2 weeks ago

There's other circumstances besides is_file && is_readable when file_get_contents may return false. This is a defensive change to prevent TypeErrors when calling trim()

welcome[bot] commented 2 weeks ago

Thanks for opening your first pull request! If you haven't yet signed our Contributor License Agreement (CLA), then please do so that we can accept your contribution. A link should appear shortly in this PR if you have not already signed one.

linux-foundation-easycla[bot] commented 2 weeks ago

CLA Signed

The committers listed above are authorized under a signed CLA.

jspaetzel commented 2 weeks ago

Will follow-up on CLA asap

codecov[bot] commented 1 week ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 73.66%. Comparing base (38633fb) to head (0fb4683). Report is 1 commits behind head on main.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/open-telemetry/opentelemetry-php/pull/1430/graphs/tree.svg?width=650&height=150&src=pr&token=OE661REHqm&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry)](https://app.codecov.io/gh/open-telemetry/opentelemetry-php/pull/1430?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry) ```diff @@ Coverage Diff @@ ## main #1430 +/- ## ============================================ + Coverage 73.55% 73.66% +0.10% - Complexity 2683 2685 +2 ============================================ Files 387 387 Lines 7975 7977 +2 ============================================ + Hits 5866 5876 +10 + Misses 2109 2101 -8 ``` | [Flag](https://app.codecov.io/gh/open-telemetry/opentelemetry-php/pull/1430/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry) | Coverage Δ | | |---|---|---| | [8.1](https://app.codecov.io/gh/open-telemetry/opentelemetry-php/pull/1430/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry) | `73.22% <100.00%> (-0.06%)` | :arrow_down: | | [8.2](https://app.codecov.io/gh/open-telemetry/opentelemetry-php/pull/1430/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry) | `73.49% <100.00%> (+<0.01%)` | :arrow_up: | | [8.3](https://app.codecov.io/gh/open-telemetry/opentelemetry-php/pull/1430/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry) | `73.59% <100.00%> (+0.13%)` | :arrow_up: | | [8.4](https://app.codecov.io/gh/open-telemetry/opentelemetry-php/pull/1430/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry) | `73.47% <100.00%> (+0.02%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files with missing lines](https://app.codecov.io/gh/open-telemetry/opentelemetry-php/pull/1430?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry) | Coverage Δ | | |---|---|---| | [src/SDK/Resource/Detectors/Host.php](https://app.codecov.io/gh/open-telemetry/opentelemetry-php/pull/1430?src=pr&el=tree&filepath=src%2FSDK%2FResource%2FDetectors%2FHost.php&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry#diff-c3JjL1NESy9SZXNvdXJjZS9EZXRlY3RvcnMvSG9zdC5waHA=) | `70.45% <100.00%> (+1.40%)` | :arrow_up: | ... and [5 files with indirect coverage changes](https://app.codecov.io/gh/open-telemetry/opentelemetry-php/pull/1430/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry) ------ [Continue to review full report in Codecov by Sentry](https://app.codecov.io/gh/open-telemetry/opentelemetry-php/pull/1430?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry) > `Δ = absolute (impact)`, `ø = not affected`, `? = missing data` > Powered by [Codecov](https://app.codecov.io/gh/open-telemetry/opentelemetry-php/pull/1430?dropdown=coverage&src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry). Last update [38633fb...0fb4683](https://app.codecov.io/gh/open-telemetry/opentelemetry-php/pull/1430?dropdown=coverage&src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry).
brettmc commented 1 week ago

@jspaetzel can you run php-cs-fixer to resolve its complaint? Otherwise LGTM and just waiting on CLA to be signed :)

jspaetzel commented 1 week ago

:heavy_check_mark: Thanks y'all!