zerobounce-sdk 1.2.0 → 2.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 05ca50ba9671572511cbd49f67ab96fd7b2956e7143ccbcc03e4a53daaed8601
4
- data.tar.gz: 863f281ff04f36fc68b7d87468056c58ceff7426318c86f6c4030bfd3f036b29
3
+ metadata.gz: 0ad61a7b25f176cba88173c9da307a70ac39a4526ff754f249c6a1d5aa58c598
4
+ data.tar.gz: 2de69f283fcfaeb2b1dfa7a8737c52353a7a3e54a7db40af28d0841ccb271a33
5
5
  SHA512:
6
- metadata.gz: 0577e5dbe7e0d013efc8da85ba6691df0adc88c5e519be4453696f40b14fb89374b7afcdd20ef053ceeff287965a3f3639489cc84752407ca6540e8a0ec1af91
7
- data.tar.gz: c5d789f36349693e1a5dce55db8613e4ccd9017864ec7617bedb837cb5d36f049b4387163183773282abc45e4c451eb53aa85119f99ea0bd549e95eeff2f4241
6
+ metadata.gz: d822a0fbfbded2214b11769169462c9148afac977edf7975e1ba960710e78fce5ac8b104b896779177e1e9685ec7fa39153dca00d0e6ded5f934ab8738969ae9
7
+ data.tar.gz: e0e097b43500401d4c0f8c737ffd9cabf9254132aa7da5774603db371363487277fc4738c15738881ef95b50535b555e3a723619a2fffef47d1c555ac57971c3
data/.env.example ADDED
@@ -0,0 +1,3 @@
1
+ # ZeroBounce API key (standard). Get your key at https://www.zerobounce.net/docs/api-dashboard
2
+ # Copy this file to .env and set your key.
3
+ ZEROBOUNCE_API_KEY=your_api_key_here
@@ -0,0 +1,5 @@
1
+ addReviewers: false
2
+ addAssignees: true
3
+ assignees:
4
+ - franciscbalint
5
+ numberOfAssignees: 1
@@ -0,0 +1,21 @@
1
+ name: Auto Assign
2
+
3
+ on:
4
+ pull_request_target:
5
+ types:
6
+ - opened
7
+ - synchronize
8
+ - reopened
9
+
10
+ permissions:
11
+ contents: read
12
+ pull-requests: write
13
+
14
+ jobs:
15
+ add-assignee:
16
+ name: Auto assign (me only)
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: kentaro-m/auto-assign-action@v2.0.1
20
+ with:
21
+ configuration-path: ".github/auto_assign.yml"
@@ -0,0 +1,105 @@
1
+ # For most projects, this workflow file will not need changing; you simply need
2
+ # to commit it to your repository.
3
+ #
4
+ # You may wish to alter this file to override the set of languages analyzed,
5
+ # or to provide custom queries or build logic.
6
+ #
7
+ # ******** NOTE ********
8
+ # We have attempted to detect the languages in your repository. Please check
9
+ # the `language` matrix defined below to confirm you have the correct set of
10
+ # supported CodeQL languages.
11
+ #
12
+ name: "CodeQL Advanced"
13
+
14
+ on:
15
+ push:
16
+ branches: [ "develop" ]
17
+ pull_request:
18
+ branches: [ "develop" ]
19
+ schedule:
20
+ - cron: '19 14 * * 4'
21
+
22
+ permissions:
23
+ security-events: write
24
+ packages: read
25
+ actions: read
26
+ contents: read
27
+
28
+ jobs:
29
+ analyze:
30
+ name: Analyze (${{ matrix.language }})
31
+ # Runner size impacts CodeQL analysis time. To learn more, please see:
32
+ # - https://gh.io/recommended-hardware-resources-for-running-codeql
33
+ # - https://gh.io/supported-runners-and-hardware-resources
34
+ # - https://gh.io/using-larger-runners (GitHub.com only)
35
+ # Consider using larger runners or machines with greater resources for possible analysis time improvements.
36
+ runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
37
+ permissions:
38
+ # required for all workflows
39
+ security-events: write
40
+
41
+ # required to fetch internal or private CodeQL packs
42
+ packages: read
43
+
44
+ # only required for workflows in private repositories
45
+ actions: read
46
+ contents: read
47
+
48
+ strategy:
49
+ fail-fast: false
50
+ matrix:
51
+ include:
52
+ - language: ruby
53
+ build-mode: none
54
+ # CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'rust', 'swift'
55
+ # Use `c-cpp` to analyze code written in C, C++ or both
56
+ # Use 'java-kotlin' to analyze code written in Java, Kotlin or both
57
+ # Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
58
+ # To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
59
+ # see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
60
+ # If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
61
+ # your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
62
+ steps:
63
+ - name: Checkout repository
64
+ uses: actions/checkout@v6
65
+
66
+ # Add any setup steps before running the `github/codeql-action/init` action.
67
+ # This includes steps like installing compilers or runtimes (`actions/setup-node`
68
+ # or others). This is typically only required for manual builds.
69
+ # - name: Setup runtime (example)
70
+ # uses: actions/setup-example@v1
71
+
72
+ # Initializes the CodeQL tools for scanning.
73
+ - name: Initialize CodeQL
74
+ uses: github/codeql-action/init@v4
75
+ with:
76
+ languages: ${{ matrix.language }}
77
+ build-mode: ${{ matrix.build-mode }}
78
+ # If you wish to specify custom queries, you can do so here or in a config file.
79
+ # By default, queries listed here will override any specified in a config file.
80
+ # Prefix the list here with "+" to use these queries and those in the config file.
81
+
82
+ # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
83
+ # queries: security-extended,security-and-quality
84
+
85
+ # If the analyze step fails for one of the languages you are analyzing with
86
+ # "We were unable to automatically build your code", modify the matrix above
87
+ # to set the build mode to "manual" for that language. Then modify this step
88
+ # to build your code.
89
+ # ℹ️ Command-line programs to run using the OS shell.
90
+ # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
91
+ - name: Run manual build steps
92
+ if: matrix.build-mode == 'manual'
93
+ shell: bash
94
+ run: |
95
+ echo 'If you are using a "manual" build mode for one or more of the' \
96
+ 'languages you are analyzing, replace this with the commands to build' \
97
+ 'your code, for example:'
98
+ echo ' make bootstrap'
99
+ echo ' make release'
100
+ exit 1
101
+
102
+ - name: Perform CodeQL Analysis
103
+ uses: github/codeql-action/analyze@v4
104
+ with:
105
+ category: "/language:${{matrix.language}}"
@@ -0,0 +1,29 @@
1
+ # Run RSpec tests (VCR cassettes; no live API key needed for recorded specs).
2
+ name: SDK CI
3
+
4
+ on:
5
+ pull_request:
6
+ types: [opened, synchronize, reopened]
7
+ push:
8
+ branches: [main, master]
9
+
10
+ permissions:
11
+ contents: read
12
+
13
+ jobs:
14
+ test:
15
+ name: Test
16
+ runs-on: ubuntu-latest
17
+ env:
18
+ ZEROBOUNCE_API_KEY: "invalid_key_for_tests"
19
+ steps:
20
+ - uses: actions/checkout@v6
21
+
22
+ - name: Set up Ruby
23
+ uses: ruby/setup-ruby@v1
24
+ with:
25
+ ruby-version: "3.2"
26
+ bundler-cache: true
27
+
28
+ - name: Run specs
29
+ run: bundle exec rspec
data/.gitignore CHANGED
@@ -62,3 +62,6 @@ build-iPhoneSimulator/
62
62
  # Log files
63
63
  output.err
64
64
  output.log
65
+
66
+ .DS_Store
67
+ .env
data/CODE_OF_CONDUCT.md CHANGED
@@ -54,12 +54,7 @@ further defined and clarified by project maintainers.
54
54
 
55
55
  ## Enforcement
56
56
 
57
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at afrase91@gmail.com. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the project team at **integrations@zerobounce.net**. All complaints will be reviewed and investigated promptly and fairly. The project team is obligated to maintain confidentiality with regard to the reporter of an incident.
63
58
 
64
59
  Project maintainers who do not follow or enforce the Code of Conduct in good
65
60
  faith may face temporary or permanent repercussions as determined by other
data/CONTRIBUTING.md CHANGED
@@ -1 +1,112 @@
1
- TODO fill this out
1
+ # Contributing to Zero Bounce Ruby SDK
2
+
3
+ Thank you for your interest in contributing. This document explains how to get set up, run tests, and submit changes.
4
+
5
+ ## Code of Conduct
6
+
7
+ By participating in this project, you agree to uphold our [Code of Conduct](CODE_OF_CONDUCT.md).
8
+
9
+ ## Getting Started
10
+
11
+ ### Prerequisites
12
+
13
+ * Ruby 3.2+ (see [.ruby-version](.ruby-version))
14
+ * [Bundler](https://bundler.io/) ~> 2.4
15
+
16
+ ### Setup
17
+
18
+ ```bash
19
+ git clone https://github.com/zerobounce/zero-bounce-ruby.git
20
+ cd zero-bounce-ruby
21
+ bundle install
22
+ ```
23
+
24
+ ### Running Tests
25
+
26
+ Tests use [RSpec](https://rspec.info/) with [VCR](https://github.com/vcr/vcr) for recorded HTTP interactions. Use the placeholder key so cassettes match:
27
+
28
+ ```bash
29
+ ZEROBOUNCE_API_KEY=vcr_test_key bundle exec rspec
30
+ ```
31
+
32
+ Or copy `.env.example` to `.env`, set `ZEROBOUNCE_API_KEY=vcr_test_key`, then:
33
+
34
+ ```bash
35
+ bundle exec rspec
36
+ ```
37
+
38
+ **With Docker:**
39
+
40
+ ```bash
41
+ docker build -t zerobounce-ruby-test .
42
+ docker run --rm zerobounce-ruby-test
43
+ ```
44
+
45
+ ### Code Style
46
+
47
+ The project uses [RuboCop](https://github.com/rubocop/rubocop). Run before submitting:
48
+
49
+ ```bash
50
+ bundle exec rubocop
51
+ ```
52
+
53
+ ## How to Contribute
54
+
55
+ ### Reporting Bugs
56
+
57
+ Open an [issue](https://github.com/zerobounce/zero-bounce-ruby/issues) and include:
58
+
59
+ * Ruby version (`ruby -v`)
60
+ * Steps to reproduce
61
+ * Expected vs actual behavior
62
+ * Relevant code or error messages
63
+
64
+ ### Suggesting Changes
65
+
66
+ * Check existing issues and pull requests first.
67
+ * Open an issue to discuss larger changes or API design before coding.
68
+
69
+ ### Submitting Changes
70
+
71
+ 1. **Fork** the repository and create a branch from `main`:
72
+ ```bash
73
+ git checkout -b feature/your-feature-name
74
+ ```
75
+
76
+ 2. **Make your changes** and add or update tests where relevant.
77
+
78
+ 3. **Run the suite** and RuboCop:
79
+ ```bash
80
+ ZEROBOUNCE_API_KEY=vcr_test_key bundle exec rspec
81
+ bundle exec rubocop
82
+ ```
83
+
84
+ 4. **Commit** with a clear message (e.g. `Add X`, `Fix Y`).
85
+
86
+ 5. **Push** your branch and open a **Pull Request** against `main`.
87
+
88
+ 6. In the PR description, briefly explain what changed and why. Link any related issues.
89
+
90
+ Maintainers will review and may request changes. Once approved, your PR can be merged.
91
+
92
+ ## Project Layout
93
+
94
+ * `lib/` – SDK source (entry point: `lib/zerobounce.rb`)
95
+ * `spec/` – RSpec tests and VCR cassettes (`spec/cassettes/`)
96
+ * `data/` – Sample CSV files for batch validation and scoring examples
97
+
98
+ ## Re-recording VCR Cassettes
99
+
100
+ If you change or add API calls and need to re-record cassettes:
101
+
102
+ 1. Use a valid Zero Bounce API key (e.g. from [dashboard](https://www.zerobounce.net/docs/api-dashboard)).
103
+ 2. Set `ZEROBOUNCE_API_KEY` and run the specs; VCR will record new HTTP interactions.
104
+ 3. Replace any real API key in the new cassette files with `vcr_test_key` before committing, so the repo never contains real credentials.
105
+
106
+ ## Questions
107
+
108
+ * [Zero Bounce API docs](https://www.zerobounce.net/docs/)
109
+ * [Project homepage](https://zerobounce.net)
110
+ * Contact: **integrations@zerobounce.net**
111
+
112
+ Thanks for contributing.
data/Dockerfile ADDED
@@ -0,0 +1,15 @@
1
+ # ZeroBounce Ruby SDK – test image (Ruby 3.2)
2
+ FROM ruby:3.2-alpine
3
+
4
+ RUN apk add --no-cache build-base git
5
+
6
+ WORKDIR /app
7
+
8
+ COPY . .
9
+ RUN bundle config set --local path 'vendor/bundle' && \
10
+ bundle install
11
+
12
+ # Dummy key for VCR/cassette-based specs; override with env for live API
13
+ ENV ZEROBOUNCE_API_KEY="${ZEROBOUNCE_API_KEY:-invalid_key_for_tests}"
14
+
15
+ CMD ["bundle", "exec", "rspec"]
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- zerobounce-sdk (1.2.0)
4
+ zerobounce-sdk (2.0.13)
5
5
  dotenv
6
6
  rest-client (~> 2.1)
7
7
 
@@ -11,6 +11,8 @@ GEM
11
11
  addressable (2.8.4)
12
12
  public_suffix (>= 2.0.2, < 6.0)
13
13
  ast (2.4.2)
14
+ base64 (0.3.0)
15
+ bigdecimal (4.0.1)
14
16
  coderay (1.1.3)
15
17
  crack (0.4.5)
16
18
  rexml
@@ -105,6 +107,8 @@ PLATFORMS
105
107
  x86_64-linux
106
108
 
107
109
  DEPENDENCIES
110
+ base64
111
+ bigdecimal
108
112
  bundler (~> 2.4.6)
109
113
  pry (~> 0.14.1)
110
114
  rake (~> 13.0)
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 ZeroBounce
3
+ Copyright (c) 2026 ZeroBounce
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
- The MIT License (MIT)
1
+ MIT License
2
2
 
3
- Copyright (c) 2018 Aaron Frase
3
+ Copyright (c) 2026 ZeroBounce
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
9
  copies of the Software, and to permit persons to whom the Software is
10
10
  furnished to do so, subject to the following conditions:
11
11
 
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
14
 
15
15
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
16
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
17
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -189,10 +189,13 @@ Zerobounce.api_usage(Date.today, Date.today)
189
189
  "sub_status_mailbox_quota_exceeded"=>0,
190
190
  "sub_status_forcible_disconnect"=>0,
191
191
  "sub_status_failed_smtp_connection"=>0,
192
+ "sub_status_accept_all"=>0,
192
193
  "sub_status_mx_forward"=>0,
193
194
  "sub_status_alternate"=>0,
194
- "sub_status_blocked"=>0,
195
195
  "sub_status_allowed"=>0,
196
+ "sub_status_blocked"=>0,
197
+ "sub_status_gold"=>0,
198
+ "sub_status_role_based_accept_all"=>0,
196
199
  "start_date"=>"4/28/2023",
197
200
  "end_date"=>"4/28/2023"}
198
201
  ```
@@ -705,14 +708,22 @@ gem install bundler -v "~>2.4.6"
705
708
  bundle install
706
709
  ```
707
710
 
708
- ### Run tests
711
+ ### Run tests with Docker
712
+ From the **parent repository root** (the folder that contains all SDKs and `docker-compose.yml`):
713
+
714
+ ```bash
715
+ docker compose build ruby
716
+ docker compose run --rm ruby
717
+ ```
718
+
719
+ ### Run tests (local)
709
720
  ```bash
710
721
  bundle exec rspec
711
722
  ```
712
723
 
713
724
  You should see an output like this
714
725
  ```bash
715
- running mock tests
726
+ running tests
716
727
  .....................................................
717
728
 
718
729
  Finished in 6.81 seconds (files took 0.40587 seconds to load)
@@ -720,24 +731,20 @@ Finished in 6.81 seconds (files took 0.40587 seconds to load)
720
731
  ```
721
732
 
722
733
  ### Test parameters
723
- The tests use the following environment parameters:
724
- ZEROBOUNCE_API_KEY {<zerobounce-api-key-value>} this key is used in mock tests as a valid key sample (any value will work for mock tests)
725
- INCORRECT_API_KEY {any non whitespace string value that is not a valid key} used for tests where the requests are meant to fail due to the API key value.
734
+ The tests use the following environment parameter:
735
+ - **ZEROBOUNCE_API_KEY** Your API key; used in mock tests as the valid key sample (any value will work for mock tests).
726
736
 
727
- To set them
737
+ An invalid API key for error-handling tests is hardcoded in the spec; no env var is required.
738
+
739
+ To set your key:
728
740
  ```bash
729
- export ZEROBOUNCE_API_KEY=99e7ef20ceea4480a173b07b1be75371
730
- export INCORRECT_API_KEY=thiskeyisinvalidorotherwiseincorrect
741
+ export ZEROBOUNCE_API_KEY=your_api_key_here
731
742
  ```
732
743
 
733
- A .env.sample file is provided.
744
+ A .env.example file is provided.
734
745
 
735
- Tests use webmock and vcr for mocking HTTP requests. This means that actual requests were made and recorded in the spec/cassettes with an (at the time) valid API key used for testing purposes. This key has been invalidated in the meantime, however it is provided in the .env.sample file for the mock tests to work. If you do not wish to use this key for mocks, you can replace it with any value in the .yml files under spec/cassettes or delete all of them and rerun the tests so that vcr records them with a new key.
746
+ Tests use webmock and vcr for mocking HTTP requests. This means that actual requests were made and recorded in the spec/cassettes with an (at the time) valid API key used for testing purposes. This key has been invalidated in the meantime, however it is provided in the .env.example file for the mock tests to work. If you do not wish to use this key for mocks, you can replace it with any value in the .yml files under spec/cassettes or delete all of them and rerun the tests so that vcr records them with a new key.
736
747
 
737
- ### Publish
738
- ```bash
739
- gem signin
740
- gem build zerobounce.spec
741
- gem push zerobounce-sdk-<version>.gem
742
- gem search zerobounce-sdk --remote
743
- ```
748
+ ## Publish
749
+
750
+ See the [sdk-docs (RubyGems)](../sdk-docs/rubygems/) guide in the SDKs repo for build and `gem push` steps.
data/SECURITY.md ADDED
@@ -0,0 +1,21 @@
1
+ # Security Policy
2
+
3
+ ## Reporting a Vulnerability
4
+
5
+ If you think you've found a security issue, please report it privately instead of opening a public issue.
6
+
7
+ **Email:** integrations@zerobounce.net (use a subject like `[zero-bounce-ruby] Security`).
8
+
9
+ We'll look into reports as we can. If the issue is in the Zero Bounce API or service rather than this SDK, we may forward it to the right team.
10
+
11
+ ## Supported Versions
12
+
13
+ We focus on the current release line for fixes. Using the [latest version](https://rubygems.org/gems/zerobounce-sdk) is recommended.
14
+
15
+ ## Tips for Using This SDK
16
+
17
+ * Don't commit API keys or `.env` files—use environment variables or a secrets manager.
18
+ * Keep dependencies up to date with `bundle install` and upgrade when new versions are released.
19
+ * The client uses HTTPS by default; avoid overriding to non-HTTPS in production.
20
+
21
+ Thanks for helping keep things secure.
data/documentation.md CHANGED
@@ -76,10 +76,13 @@ Zerobounce.api_usage(Date.today, Date.today)
76
76
  "sub_status_mailbox_quota_exceeded"=>0,
77
77
  "sub_status_forcible_disconnect"=>0,
78
78
  "sub_status_failed_smtp_connection"=>0,
79
+ "sub_status_accept_all"=>0,
79
80
  "sub_status_mx_forward"=>0,
80
81
  "sub_status_alternate"=>0,
81
- "sub_status_blocked"=>0,
82
82
  "sub_status_allowed"=>0,
83
+ "sub_status_blocked"=>0,
84
+ "sub_status_gold"=>0,
85
+ "sub_status_role_based_accept_all"=>0,
83
86
  "start_date"=>"4/28/2023",
84
87
  "end_date"=>"4/28/2023"}
85
88
  ```
@@ -496,17 +499,17 @@ Finished in 6.81 seconds (files took 0.40587 seconds to load)
496
499
 
497
500
  ##### Test parameters
498
501
  The tests use the following environment parameters:
499
- TEST {unit|live} influences whether mocked unit tests are run or the live server is used (credits may be used if you choose to do this)
500
- ZEROBOUNCE_API_KEY {<zerobounce-api-key-value>} this key is used to make requests to the live server; it is also used in mock tests as a valid key sample (any value will work for mock tests)
501
- INCORRECT_API_KEY {any non whitespace string value that is not a valid key} used for tests where the requests are meant to fail due to the API key value.
502
+ - **TEST** {unit|live} Influences whether mocked unit tests are run or the live server is used (credits may be used if you choose to do this).
503
+ - **ZEROBOUNCE_API_KEY** Your API key; used to make requests to the live server and in mock tests as the valid key sample (any value will work for mock tests).
504
+
505
+ An invalid API key for error-handling tests is hardcoded in the spec; no env var is required.
502
506
 
503
- To set them
507
+ To set them:
504
508
  ```bash
505
- export ZEROBOUNCE_API_KEY=99e7ef20ceea4480a173b07b1be75371
506
- export INCORRECT_API_KEY=thiskeyisinvalidorotherwiseincorrect
509
+ export ZEROBOUNCE_API_KEY=your_api_key_here
507
510
  export TEST=unit
508
511
  ```
509
512
 
510
- A .env.sample file is provided.
513
+ A .env.example file is provided.
511
514
 
512
- Mock tests were generated using webmock and vcr. This means that actual requests were made and recorded in the spec/cassettes with an (at the time) valid API key used for testing purposes. This key has been invalidated in the meantime, however it is provided in the .env.sample file for the mock tests to work. If you do not wish to use this key for mocks, you can replace it with any value in the .yml files under spec/cassettes or delete all of them and rerun the tests so that vcr records them with a new key.
515
+ Mock tests were generated using webmock and vcr. This means that actual requests were made and recorded in the spec/cassettes with an (at the time) valid API key used for testing purposes. This key has been invalidated in the meantime, however it is provided in the .env.example file for the mock tests to work. If you do not wish to use this key for mocks, you can replace it with any value in the .yml files under spec/cassettes or delete all of them and rerun the tests so that vcr records them with a new key.
@@ -13,6 +13,34 @@ module Zerobounce
13
13
 
14
14
  protected
15
15
 
16
+ # Strips trailing slashes from root URL without using a regex (avoids ReDoS).
17
+ def self.__root_without_trailing_slashes__(root)
18
+ s = root.to_s
19
+ s = s.chomp('/') while s.end_with?('/')
20
+ s
21
+ end
22
+
23
+ # Resolves and validates filepath to prevent path traversal (e.g. ../../etc/passwd).
24
+ # Returns a canonical path only if the file is under the current directory and is a regular file.
25
+ def self.__safe_file_path__(filepath)
26
+ raise ArgumentError, 'File path is required' if filepath.nil? || filepath.to_s.empty?
27
+ filepath = filepath.to_s
28
+ expanded = File.expand_path(filepath)
29
+ base = File.realpath(Dir.pwd)
30
+ base_with_sep = base + File::SEPARATOR
31
+ unless expanded == base || expanded.start_with?(base_with_sep)
32
+ raise ArgumentError, 'File path must be under the current directory'
33
+ end
34
+ canonical = File.realpath(expanded)
35
+ unless canonical == base || canonical.start_with?(base_with_sep)
36
+ raise ArgumentError, 'File path must be under the current directory'
37
+ end
38
+ unless File.file?(canonical)
39
+ raise ArgumentError, 'File path must point to a regular file'
40
+ end
41
+ canonical
42
+ end
43
+
16
44
  def self._get(root, path, params, content_type='application/json')
17
45
 
18
46
  # puts path
@@ -21,7 +49,7 @@ module Zerobounce
21
49
  raise ("API key must be assigned") if not Zerobounce.config.apikey
22
50
 
23
51
  params[:api_key] = Zerobounce.config.apikey
24
- url = "#{root}/#{path}"
52
+ url = "#{Zerobounce::BaseRequest.__root_without_trailing_slashes__(root)}/#{path}"
25
53
 
26
54
  response = RestClient.get(url, {params: params})
27
55
  return response
@@ -32,11 +60,11 @@ module Zerobounce
32
60
  raise ("API key must be assigned") if not Zerobounce.config.apikey
33
61
 
34
62
  params[:api_key] = Zerobounce.config.apikey
35
- url = "#{root}/#{path}"
63
+ url = "#{Zerobounce::BaseRequest.__root_without_trailing_slashes__(root)}/#{path}"
36
64
  response = nil
37
65
 
38
66
  if filepath or content_type == 'multipart/form-data'
39
- params[:file] = File.new(filepath, 'rb')
67
+ params[:file] = File.new(Zerobounce::BaseRequest.__safe_file_path__(filepath), 'rb')
40
68
  params[:multipart] = true
41
69
  response = RestClient.post(url, params)
42
70
 
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zerobounce
4
+ # Validation status values returned by the API (validate, validate_batch).
5
+ # Use for comparison: response['status'] == Zerobounce::ValidateStatus::VALID
6
+ # Unknown/future API values are not listed; compare against response['status'] as string.
7
+ module ValidateStatus
8
+ NONE = ''
9
+ VALID = 'valid'
10
+ INVALID = 'invalid'
11
+ CATCH_ALL = 'catch-all'
12
+ UNKNOWN = 'unknown'
13
+ SPAMTRAP = 'spamtrap'
14
+ ABUSE = 'abuse'
15
+ DO_NOT_MAIL = 'do_not_mail'
16
+ end
17
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zerobounce
4
+ # Validation sub-status values returned by the API (validate, validate_batch).
5
+ # Use for comparison: response['sub_status'] == Zerobounce::ValidateSubStatus::ACCEPT_ALL
6
+ # Unknown/future API values are not listed; compare against response['sub_status'] as string.
7
+ module ValidateSubStatus
8
+ NONE = ''
9
+ ANTISPAM_SYSTEM = 'antispam_system'
10
+ GREYLISTED = 'greylisted'
11
+ MAIL_SERVER_TEMPORARY_ERROR = 'mail_server_temporary_error'
12
+ FORCIBLE_DISCONNECT = 'forcible_disconnect'
13
+ MAIL_SERVER_DID_NOT_RESPOND = 'mail_server_did_not_respond'
14
+ TIMEOUT_EXCEEDED = 'timeout_exceeded'
15
+ FAILED_SMTP_CONNECTION = 'failed_smtp_connection'
16
+ MAILBOX_QUOTA_EXCEEDED = 'mailbox_quota_exceeded'
17
+ EXCEPTION_OCCURRED = 'exception_occurred'
18
+ POSSIBLE_TRAP = 'possible_trap'
19
+ ROLE_BASED = 'role_based'
20
+ GLOBAL_SUPPRESSION = 'global_suppression'
21
+ MAILBOX_NOT_FOUND = 'mailbox_not_found'
22
+ NO_DNS_ENTRIES = 'no_dns_entries'
23
+ FAILED_SYNTAX_CHECK = 'failed_syntax_check'
24
+ POSSIBLE_TYPO = 'possible_typo'
25
+ UNROUTABLE_IP_ADDRESS = 'unroutable_ip_address'
26
+ LEADING_PERIOD_REMOVED = 'leading_period_removed'
27
+ DOES_NOT_ACCEPT_MAIL = 'does_not_accept_mail'
28
+ ALIAS_ADDRESS = 'alias_address'
29
+ ROLE_BASED_CATCH_ALL = 'role_based_catch_all'
30
+ DISPOSABLE = 'disposable'
31
+ TOXIC = 'toxic'
32
+ ALTERNATE = 'alternate'
33
+ MX_FORWARD = 'mx_forward'
34
+ BLOCKED = 'blocked'
35
+ ALLOWED = 'allowed'
36
+ ACCEPT_ALL = 'accept_all'
37
+ ROLE_BASED_ACCEPT_ALL = 'role_based_accept_all'
38
+ GOLD = 'gold'
39
+ end
40
+ end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Zerobounce
4
4
  # The version of the gem.
5
- VERSION = '1.2.0'
5
+ VERSION = '2.0.13'
6
6
  end