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

[bug] - Handle empty reader case in newFileReader #2854

Merged
merged 3 commits into from
May 16, 2024

Conversation

ahrav
Copy link
Collaborator

@ahrav ahrav commented May 16, 2024

Description:

This PR introduces changes to handle the scenario where newFileReader receives an empty reader. Previously, when an empty reader was passed to newFileReader, it would result in an error and halt processing of that archive.

Changes:

  • Introduce a new sentinel error ErrEmptyReader to represent the case when the reader is empty.
  • Modify the newFileReader function to check if the size of the BufferedFileReader is zero, indicating an empty reader.
    • If the reader is empty, return a zero value reader and the ErrEmptyReader error.
  • Update the usage of newFileReader to handle the ErrEmptyReader error explicitly.
    • If ErrEmptyReader is returned, log a message indicating that the reader is empty and skip the file by returning nil.

Checklist:

  • Tests passing (make test-community)?
  • Lint passing (make lint this requires golangci-lint)?

@ahrav ahrav linked an issue May 16, 2024 that may be closed by this pull request
@@ -21,7 +21,7 @@ const (

var (
maxDepth = 5
maxSize = 250 * 1024 * 1024 // 250 MB
maxSize = 2 << 30 // 2 GB
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Reverted this to the old value. This should no longer be an issue since we do not read the entire file into memory.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I considered removing it, but to preserve backward compatibility, I left it in. This value can be configured via a command-line flag, so removing it isn't straightforward. 😞

@ahrav ahrav force-pushed the 2853-failing-to-scan-archived-files branch from 34390df to 565c7c7 Compare May 16, 2024 01:06
@ahrav ahrav requested a review from a team May 16, 2024 01:07
@ahrav ahrav marked this pull request as ready for review May 16, 2024 01:07
@ahrav ahrav requested a review from a team as a code owner May 16, 2024 01:07
@ahrav ahrav merged commit 2db06f0 into main May 16, 2024
12 checks passed
@ahrav ahrav deleted the 2853-failing-to-scan-archived-files branch May 16, 2024 01:25
itsacoyote pushed a commit to matter-labs/docs-nuxt-template that referenced this pull request May 16, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
|
[trufflesecurity/trufflehog](https://togithub.com/trufflesecurity/trufflehog)
| action | patch | `v3.76.0` -> `v3.76.2` |

---

### Release Notes

<details>
<summary>trufflesecurity/trufflehog
(trufflesecurity/trufflehog)</summary>

###
[`v3.76.2`](https://togithub.com/trufflesecurity/trufflehog/releases/tag/v3.76.2)

[Compare
Source](https://togithub.com/trufflesecurity/trufflehog/compare/v3.76.1...v3.76.2)

#### What's Changed

- \[bug] - Handle empty reader case in newFileReader by
[@&#8203;ahrav](https://togithub.com/ahrav) in
[trufflesecurity/trufflehog#2854

**Full Changelog**:
trufflesecurity/trufflehog@v3.76.1...v3.76.2

###
[`v3.76.1`](https://togithub.com/trufflesecurity/trufflehog/releases/tag/v3.76.1)

[Compare
Source](https://togithub.com/trufflesecurity/trufflehog/compare/v3.76.0...v3.76.1)

#### What's Changed

- chore: fix some typos in comments by
[@&#8203;cuiyourong](https://togithub.com/cuiyourong) in
[trufflesecurity/trufflehog#2851
- Added user's email and location in metadata for Github detector. by
[@&#8203;abmussani](https://togithub.com/abmussani) in
[trufflesecurity/trufflehog#2850
- \[refactor] - Create separate handler for non-archive data by
[@&#8203;ahrav](https://togithub.com/ahrav) in
[trufflesecurity/trufflehog#2825

#### New Contributors

- [@&#8203;cuiyourong](https://togithub.com/cuiyourong) made their first
contribution in
[trufflesecurity/trufflehog#2851

**Full Changelog**:
trufflesecurity/trufflehog@v3.76.0...v3.76.1

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/matter-labs/docs-nuxt-template).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zNjMuNSIsInVwZGF0ZWRJblZlciI6IjM3LjM2My41IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
haraldh added a commit to matter-labs/vault-auth-tee that referenced this pull request May 21, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
|
[trufflesecurity/trufflehog](https://togithub.com/trufflesecurity/trufflehog)
| action | minor | `v3.75.1` -> `v3.76.3` |

---

### Release Notes

<details>
<summary>trufflesecurity/trufflehog
(trufflesecurity/trufflehog)</summary>

###
[`v3.76.3`](https://togithub.com/trufflesecurity/trufflehog/releases/tag/v3.76.3)

[Compare
Source](https://togithub.com/trufflesecurity/trufflehog/compare/v3.76.2...v3.76.3)

#### What's Changed

- fix(deps): update module github.com/aws/aws-sdk-go to v1.53.3 by
[@&#8203;renovate](https://togithub.com/renovate) in
[trufflesecurity/trufflehog#2849
- Integromat detector - Deprecated by
[@&#8203;abmussani](https://togithub.com/abmussani) in
[trufflesecurity/trufflehog#2856
- add tolower to all keywords, and remove return on error for global
vars by [@&#8203;zricethezav](https://togithub.com/zricethezav) in
[trufflesecurity/trufflehog#2852
- Adding postman to sub-commands list by
[@&#8203;CarlesLlobet](https://togithub.com/CarlesLlobet) in
[trufflesecurity/trufflehog#2813
- \[chore] - upgrade Github dep by
[@&#8203;ahrav](https://togithub.com/ahrav) in
[trufflesecurity/trufflehog#2858
- \[chore] - move buffers pkg out of writers pkg by
[@&#8203;ahrav](https://togithub.com/ahrav) in
[trufflesecurity/trufflehog#2826
- \[refactor] - remove redundant chunking by
[@&#8203;ahrav](https://togithub.com/ahrav) in
[trufflesecurity/trufflehog#2855

#### New Contributors

- [@&#8203;CarlesLlobet](https://togithub.com/CarlesLlobet) made their
first contribution in
[trufflesecurity/trufflehog#2813

**Full Changelog**:
trufflesecurity/trufflehog@v3.76.2...v3.76.3

###
[`v3.76.2`](https://togithub.com/trufflesecurity/trufflehog/releases/tag/v3.76.2)

[Compare
Source](https://togithub.com/trufflesecurity/trufflehog/compare/v3.76.1...v3.76.2)

#### What's Changed

- \[bug] - Handle empty reader case in newFileReader by
[@&#8203;ahrav](https://togithub.com/ahrav) in
[trufflesecurity/trufflehog#2854

**Full Changelog**:
trufflesecurity/trufflehog@v3.76.1...v3.76.2

###
[`v3.76.1`](https://togithub.com/trufflesecurity/trufflehog/releases/tag/v3.76.1)

[Compare
Source](https://togithub.com/trufflesecurity/trufflehog/compare/v3.76.0...v3.76.1)

#### What's Changed

- chore: fix some typos in comments by
[@&#8203;cuiyourong](https://togithub.com/cuiyourong) in
[trufflesecurity/trufflehog#2851
- Added user's email and location in metadata for Github detector. by
[@&#8203;abmussani](https://togithub.com/abmussani) in
[trufflesecurity/trufflehog#2850
- \[refactor] - Create separate handler for non-archive data by
[@&#8203;ahrav](https://togithub.com/ahrav) in
[trufflesecurity/trufflehog#2825

#### New Contributors

- [@&#8203;cuiyourong](https://togithub.com/cuiyourong) made their first
contribution in
[trufflesecurity/trufflehog#2851

**Full Changelog**:
trufflesecurity/trufflehog@v3.76.0...v3.76.1

###
[`v3.76.0`](https://togithub.com/trufflesecurity/trufflehog/releases/tag/v3.76.0)

[Compare
Source](https://togithub.com/trufflesecurity/trufflehog/compare/v3.75.1...v3.76.0)

#### What's Changed

- fix(deps): update module golang.org/x/net to v0.25.0 by
[@&#8203;renovate](https://togithub.com/renovate) in
[trufflesecurity/trufflehog#2792
- Add webhook source protos by
[@&#8203;dustin-decker](https://togithub.com/dustin-decker) in
[trufflesecurity/trufflehog#2789
- Increase test chan size by
[@&#8203;rosecodym](https://togithub.com/rosecodym) in
[trufflesecurity/trufflehog#2797
- fix(deps): update module golang.org/x/exp to
v0.0.0-20240506185415-9bf2ced13842 by
[@&#8203;renovate](https://togithub.com/renovate) in
[trufflesecurity/trufflehog#2795
- fix(deps): update module github.com/brianvoe/gofakeit/v7 to v7.0.3 by
[@&#8203;renovate](https://togithub.com/renovate) in
[trufflesecurity/trufflehog#2798
- fix(deps): update module github.com/aws/aws-sdk-go to v1.52.4 by
[@&#8203;renovate](https://togithub.com/renovate) in
[trufflesecurity/trufflehog#2794
- fix(deps): update module google.golang.org/api to v0.178.0 by
[@&#8203;renovate](https://togithub.com/renovate) in
[trufflesecurity/trufflehog#2800
- Enterprise ReadMe Updates by
[@&#8203;theproductone](https://togithub.com/theproductone) in
[trufflesecurity/trufflehog#2803
- Updating Enterprise Readme Link from Contact to Product Info Page by
[@&#8203;theproductone](https://togithub.com/theproductone) in
[trufflesecurity/trufflehog#2804
- chore(deps): update golangci/golangci-lint-action action to v6 by
[@&#8203;renovate](https://togithub.com/renovate) in
[trufflesecurity/trufflehog#2801
- \[chore] - address linter by
[@&#8203;ahrav](https://togithub.com/ahrav) in
[trufflesecurity/trufflehog#2783
- fix(deps): update module github.com/xanzy/go-gitlab to v0.104.1 by
[@&#8203;renovate](https://togithub.com/renovate) in
[trufflesecurity/trufflehog#2784
- fix(deps): update module github.com/rabbitmq/amqp091-go to v1.10.0 by
[@&#8203;renovate](https://togithub.com/renovate) in
[trufflesecurity/trufflehog#2809
- fix(deps): update module github.com/snowflakedb/gosnowflake to v1.10.0
by [@&#8203;renovate](https://togithub.com/renovate) in
[trufflesecurity/trufflehog#2810
- Prevent panic from flaky test by
[@&#8203;rgmz](https://togithub.com/rgmz) in
[trufflesecurity/trufflehog#2817
- fix(deps): update module github.com/aws/aws-sdk-go to v1.52.6 by
[@&#8203;renovate](https://togithub.com/renovate) in
[trufflesecurity/trufflehog#2816
- fix(deps): update module github.com/hashicorp/go-retryablehttp to
v0.7.6 by [@&#8203;renovate](https://togithub.com/renovate) in
[trufflesecurity/trufflehog#2819
- fix(deps): update module github.com/charmbracelet/bubbletea to v0.26.2
by [@&#8203;renovate](https://togithub.com/renovate) in
[trufflesecurity/trufflehog#2818
- fix(deps): update module github.com/prometheus/client_golang to
v1.19.1 by [@&#8203;renovate](https://togithub.com/renovate) in
[trufflesecurity/trufflehog#2821
- Update postman flags to be less confusing by
[@&#8203;dustin-decker](https://togithub.com/dustin-decker) in
[trufflesecurity/trufflehog#2755
- \[refactor] - Refactor Archive Handling Logic by
[@&#8203;ahrav](https://togithub.com/ahrav) in
[trufflesecurity/trufflehog#2703
- fix(deps): update testcontainers-go monorepo to v0.31.0 by
[@&#8203;renovate](https://togithub.com/renovate) in
[trufflesecurity/trufflehog#2823
- fix(deps): update module github.com/xanzy/go-gitlab to v0.105.0 by
[@&#8203;renovate](https://togithub.com/renovate) in
[trufflesecurity/trufflehog#2824
- fix(deps): update module google.golang.org/api to v0.180.0 by
[@&#8203;renovate](https://togithub.com/renovate) in
[trufflesecurity/trufflehog#2822
- fix(deps): update module github.com/sassoftware/go-rpmutils to v0.4.0
by [@&#8203;renovate](https://togithub.com/renovate) in
[trufflesecurity/trufflehog#2831
- fix(deps): update module github.com/google/go-github/v61 to v62 by
[@&#8203;renovate](https://togithub.com/renovate) in
[trufflesecurity/trufflehog#2832
- Update results's extra data for Twilio by
[@&#8203;abmussani](https://togithub.com/abmussani) in
[trufflesecurity/trufflehog#2807
- fix(deps): update module github.com/aws/aws-sdk-go to v1.53.0 by
[@&#8203;renovate](https://togithub.com/renovate) in
[trufflesecurity/trufflehog#2830
- \[chore] - Update GitlabV2 detector by
[@&#8203;ahrav](https://togithub.com/ahrav) in
[trufflesecurity/trufflehog#2840
- Fixed the Now Scanning Emoji on the ReadMe by
[@&#8203;theproductone](https://togithub.com/theproductone) in
[trufflesecurity/trufflehog#2842
- fix(deps): update module github.com/fatih/color to v1.17.0 by
[@&#8203;renovate](https://togithub.com/renovate) in
[trufflesecurity/trufflehog#2837
- fix(deps): update module github.com/aws/aws-sdk-go to v1.53.1 by
[@&#8203;renovate](https://togithub.com/renovate) in
[trufflesecurity/trufflehog#2841
- Bump up performance test threshold to 50% by
[@&#8203;zricethezav](https://togithub.com/zricethezav) in
[trufflesecurity/trufflehog#2839
- Update SendGrid detector by [@&#8203;rgmz](https://togithub.com/rgmz)
in
[trufflesecurity/trufflehog#2833
- fix(deps): update module cloud.google.com/go/storage to v1.41.0 by
[@&#8203;renovate](https://togithub.com/renovate) in
[trufflesecurity/trufflehog#2843
- \[bug] - Fix case-sensitivity issue in PrefixRegex function by
[@&#8203;ahrav](https://togithub.com/ahrav) in
[trufflesecurity/trufflehog#2811
- switch to filesystem and specific tag when performance testing by
[@&#8203;zricethezav](https://togithub.com/zricethezav) in
[trufflesecurity/trufflehog#2846
- Use fake detectors in versioned detectors test by
[@&#8203;rosecodym](https://togithub.com/rosecodym) in
[trufflesecurity/trufflehog#2847
- \[feat] - Support bearer auth for docker scans by
[@&#8203;ahrav](https://togithub.com/ahrav) in
[trufflesecurity/trufflehog#2848
- Add "Intra42" detector by
[@&#8203;alexandregv](https://togithub.com/alexandregv) in
[trufflesecurity/trufflehog#2835

#### New Contributors

- [@&#8203;theproductone](https://togithub.com/theproductone) made their
first contribution in
[trufflesecurity/trufflehog#2803

**Full Changelog**:
trufflesecurity/trufflehog@v3.75.1...v3.76.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/matter-labs/vault-auth-tee).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zNTEuMiIsInVwZGF0ZWRJblZlciI6IjM3LjM2My41IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Failing to scan archived files
2 participants