Update dependency urllib3 to v1.26.10 #11
							
								
								
									
										16
									
								
								.github/workflows/merge-to-main.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										16
									
								
								.github/workflows/merge-to-main.yml
									
									
									
									
										vendored
									
									
								
							| @@ -10,6 +10,8 @@ jobs: | |||||||
|     steps: |     steps: | ||||||
|       - name: Check out repository code |       - name: Check out repository code | ||||||
|         uses: actions/checkout@v3 |         uses: actions/checkout@v3 | ||||||
|  |         with: | ||||||
|  |           fetch-depth: 0 | ||||||
|       - name: Setup Python |       - name: Setup Python | ||||||
|         uses: actions/setup-python@v4 |         uses: actions/setup-python@v4 | ||||||
|         with: |         with: | ||||||
| @@ -18,14 +20,16 @@ jobs: | |||||||
|         run: pip install -r requirements.txt && pip install -r requirements-dev.txt |         run: pip install -r requirements.txt && pip install -r requirements-dev.txt | ||||||
|       - name: Run test suite |       - name: Run test suite | ||||||
|         run: | |         run: | | ||||||
|           coverage run -m py.test -v |           coverage run -m py.test -v --junitxml=testresults.xml | ||||||
|           coverage xml |           coverage xml | ||||||
|       - name: Report results to DeepSource |       - uses: sonarsource/sonarqube-scan-action@master | ||||||
|         run: | |  | ||||||
|           curl https://deepsource.io/cli | sh |  | ||||||
|           ./bin/deepsource report --analyzer test-coverage --key python --value-file ./coverage.xml |  | ||||||
|         env: |         env: | ||||||
|           DEEPSOURCE_DSN: ${{ secrets.DEEPSOURCE_DSN }} |           SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||||||
|  |           SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} | ||||||
|  |       - uses: sonarsource/sonarqube-quality-gate-action@master | ||||||
|  |         timeout-minutes: 5 | ||||||
|  |         env: | ||||||
|  |           SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||||||
|  |  | ||||||
|   build: |   build: | ||||||
|     needs: coverage |     needs: coverage | ||||||
|   | |||||||
							
								
								
									
										17
									
								
								.github/workflows/pull-request.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										17
									
								
								.github/workflows/pull-request.yml
									
									
									
									
										vendored
									
									
								
							| @@ -16,6 +16,7 @@ jobs: | |||||||
|         uses: actions/checkout@v3 |         uses: actions/checkout@v3 | ||||||
|         with: |         with: | ||||||
|           ref: ${{ github.event.pull_request.head.sha }} |           ref: ${{ github.event.pull_request.head.sha }} | ||||||
|  |           fetch-depth: 0 | ||||||
|       - name: Setup Python |       - name: Setup Python | ||||||
|         uses: actions/setup-python@v4 |         uses: actions/setup-python@v4 | ||||||
|         with: |         with: | ||||||
| @@ -23,14 +24,16 @@ jobs: | |||||||
|       - name: Install dependencies |       - name: Install dependencies | ||||||
|         run: pip install -r requirements.txt && pip install -r requirements-dev.txt |         run: pip install -r requirements.txt && pip install -r requirements-dev.txt | ||||||
|       - name: Lint |       - name: Lint | ||||||
|         run: pylint --recursive=yes . |         run: pylint --recursive=yes --output-format=parseable --output=lintreport.txt . | ||||||
|       - name: Run test suite |       - name: Run test suite | ||||||
|         run: | |         run: | | ||||||
|           coverage run -m py.test -v |           coverage run -m py.test -v --junitxml=testresults.xml | ||||||
|           coverage xml |           coverage xml | ||||||
|       - name: Report results to DeepSource |       - uses: sonarsource/sonarqube-scan-action@master | ||||||
|         run: | |  | ||||||
|           curl https://deepsource.io/cli | sh |  | ||||||
|           ./bin/deepsource report --analyzer test-coverage --key python --value-file ./coverage.xml |  | ||||||
|         env: |         env: | ||||||
|           DEEPSOURCE_DSN: ${{ secrets.DEEPSOURCE_DSN }} |           SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||||||
|  |           SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} | ||||||
|  |       - uses: sonarsource/sonarqube-quality-gate-action@master | ||||||
|  |         timeout-minutes: 5 | ||||||
|  |         env: | ||||||
|  |           SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -38,6 +38,8 @@ pip-log.txt | |||||||
| pip-delete-this-directory.txt | pip-delete-this-directory.txt | ||||||
|  |  | ||||||
| # Unit test / coverage reports | # Unit test / coverage reports | ||||||
|  | lintreport.txt | ||||||
|  | testresults.xml | ||||||
| htmlcov/ | htmlcov/ | ||||||
| .tox/ | .tox/ | ||||||
| .nox/ | .nox/ | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| # iPilot [](https://github.com/luketainton/pypilot/actions/workflows/ci-branch-main.yml) [](https://deepsource.io/gh/luketainton/pypilot/?ref=repository-badge) | # iPilot [](https://github.com/luketainton/pypilot/actions/workflows/ci-branch-main.yml) [](https://sonarqube.tainton.uk/dashboard?id=luketainton_pypilot_AYHo1eOKSbMjdyWLhHhP) | ||||||
|  |  | ||||||
| ## Description | ## Description | ||||||
| IP Information Lookup Tool | IP Information Lookup Tool | ||||||
|   | |||||||
| @@ -2,4 +2,4 @@ | |||||||
|  |  | ||||||
| """MODULE: Specifies app version.""" | """MODULE: Specifies app version.""" | ||||||
|  |  | ||||||
| VERSION = "1.2" | VERSION = "1.2"  # pragma: no cover | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ import argparse | |||||||
| from app.query_normalisation import get_public_ip | from app.query_normalisation import get_public_ip | ||||||
|  |  | ||||||
|  |  | ||||||
| def parse_args() -> argparse.Namespace: | def parse_args() -> argparse.Namespace:  # pragma: no cover | ||||||
|     """Get arguments from user via the command line.""" |     """Get arguments from user via the command line.""" | ||||||
|     parser = argparse.ArgumentParser( |     parser = argparse.ArgumentParser( | ||||||
|         description="Query information about an IP address or domain name." |         description="Query information about an IP address or domain name." | ||||||
|   | |||||||
| @@ -2,6 +2,8 @@ | |||||||
|  |  | ||||||
| """MODULE: Provides functions to call various APIs to retrieve IP/prefix information.""" | """MODULE: Provides functions to call various APIs to retrieve IP/prefix information.""" | ||||||
|  |  | ||||||
|  | from typing import Union | ||||||
|  |  | ||||||
| import ipaddress | import ipaddress | ||||||
| import requests | import requests | ||||||
|  |  | ||||||
| @@ -24,7 +26,7 @@ def get_autonomous_system_number(as_info: str) -> str: | |||||||
|     return as_number |     return as_number | ||||||
|  |  | ||||||
|  |  | ||||||
| def get_prefix_information(autonomous_system: int) -> list: | def get_prefix_information(autonomous_system: int) -> Union[list, None]: | ||||||
|     """Retrieves prefix information about a given autonomous system.""" |     """Retrieves prefix information about a given autonomous system.""" | ||||||
|     api_endpoint = f"https://api.hackertarget.com/aslookup/?q={str(autonomous_system)}" |     api_endpoint = f"https://api.hackertarget.com/aslookup/?q={str(autonomous_system)}" | ||||||
|     try: |     try: | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ import sys | |||||||
| from app.args import parse_args | from app.args import parse_args | ||||||
| from app.print_table import print_table, generate_prefix_string | from app.print_table import print_table, generate_prefix_string | ||||||
| from app.query_normalisation import is_ip_address, resolve_domain_name | from app.query_normalisation import is_ip_address, resolve_domain_name | ||||||
| from app.ip_info import (  # pragma: no cover | from app.ip_info import ( | ||||||
|     get_ip_information, |     get_ip_information, | ||||||
|     get_autonomous_system_number, |     get_autonomous_system_number, | ||||||
|     get_prefix_information, |     get_prefix_information, | ||||||
|   | |||||||
| @@ -2,10 +2,11 @@ | |||||||
|  |  | ||||||
| """MODULE: Provides functions for preparing, then printing, retrieved data.""" | """MODULE: Provides functions for preparing, then printing, retrieved data.""" | ||||||
|  |  | ||||||
|  | from typing import Union | ||||||
| from tabulate import tabulate | from tabulate import tabulate | ||||||
|  |  | ||||||
|  |  | ||||||
| def generate_prefix_string(prefixes: list) -> str: | def generate_prefix_string(prefixes: list) -> Union[str, None]: | ||||||
|     """Generate a string that spilts prefixes into rows of 4.""" |     """Generate a string that spilts prefixes into rows of 4.""" | ||||||
|     num_per_row = 4 |     num_per_row = 4 | ||||||
|     try: |     try: | ||||||
| @@ -17,6 +18,6 @@ def generate_prefix_string(prefixes: list) -> str: | |||||||
|         return None |         return None | ||||||
|  |  | ||||||
|  |  | ||||||
| def print_table(table_data) -> None: | def print_table(table_data) -> None:  # pragma: no cover | ||||||
|     """Print table generated by tabulate.""" |     """Print table generated by tabulate.""" | ||||||
|     print(tabulate(table_data)) |     print(tabulate(table_data)) | ||||||
|   | |||||||
							
								
								
									
										9
									
								
								sonar-project.properties
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								sonar-project.properties
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | |||||||
|  | sonar.projectKey=luketainton_pypilot_AYHo1eOKSbMjdyWLhHhP | ||||||
|  | sonar.python.version=3.10 | ||||||
|  | sonar.python.coverage.reportPaths=coverage.xml | ||||||
|  | sonar.python.pylint.reportPaths=lintreport.txt | ||||||
|  | sonar.python.xunit.reportPath=testresults.xml | ||||||
|  | sonar.sources=app | ||||||
|  | sonar.tests=tests | ||||||
|  | sonar.exclusions=,.github/**,.gitignore,CODEOWNERS,CHANGELOG.md,LICENSE.md,README.md,renovate.json,requirements-dev.txt,requirements.txt | ||||||
|  | sonar.coverage.exclusions=app/_version.py,app/args.py,app/main.py | ||||||
							
								
								
									
										19
									
								
								tests/test_print_table.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								tests/test_print_table.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | |||||||
|  | #!/usr/bin/env python3 | ||||||
|  |  | ||||||
|  | """MODULE: Provides test cases for app/print_table.py.""" | ||||||
|  |  | ||||||
|  | from app.print_table import generate_prefix_string  # pragma: no cover | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def test_generate_prefix_string_small() -> None: | ||||||
|  |     """TEST: Verifies if a small prefix list results in one line.""" | ||||||
|  |     test_query = ["abc", "def"] | ||||||
|  |     result = generate_prefix_string(prefixes=test_query) | ||||||
|  |     assert result == "abc, def\n" | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def test_generate_prefix_string_large() -> None: | ||||||
|  |     """TEST: Verifies if a large prefix list results in multiple lines.""" | ||||||
|  |     test_query = ["abc", "def", "ghi", "jkl", "mno", "pqr"] | ||||||
|  |     result = generate_prefix_string(prefixes=test_query) | ||||||
|  |     assert result == "abc, def, ghi, jkl\nmno, pqr\n" | ||||||
		Reference in New Issue
	
	Block a user