diff --git a/sample_packages/sample_python_package/README.md b/sample_packages/sample_python_package/README.md new file mode 100644 index 00000000..eadd5e6c --- /dev/null +++ b/sample_packages/sample_python_package/README.md @@ -0,0 +1,9 @@ +## Sample Python package + +This package will simulate different scenarios to test package analysis on. + +To use this package for local analysis, build this package by running +`python3 -m build` in this directory. The package will be located in the dist/ +folder. + +The same license for the rest of the package analysis project applies to this package. diff --git a/sample_packages/sample_python_package/pyproject.toml b/sample_packages/sample_python_package/pyproject.toml new file mode 100644 index 00000000..dee0cf46 --- /dev/null +++ b/sample_packages/sample_python_package/pyproject.toml @@ -0,0 +1,18 @@ +[build-system] +requires = ["setuptools", "setuptools-scm"] +build-backend = "setuptools.build_meta" + +[project] +name = "sample_python_package" +version = "0.0.1" +authors = [ + { name="OpenSSF " }, +] +description = "A small example package" +readme = "README.md" +requires-python = ">=3.7" +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: Apache Software License", + "Operating System :: OS Independent", +] diff --git a/sample_packages/sample_python_package/setup.py b/sample_packages/sample_python_package/setup.py new file mode 100644 index 00000000..9790d468 --- /dev/null +++ b/sample_packages/sample_python_package/setup.py @@ -0,0 +1,12 @@ +import sys +import os +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +sys.path.append(SCRIPT_DIR) + +from setuptools import setup, find_packages +from src.example import * + +setup(name="sample_python_package", + packages=find_packages(),) + +send_https_post_request("setup.py") diff --git a/sample_packages/sample_python_package/src/__init__.py b/sample_packages/sample_python_package/src/__init__.py new file mode 100644 index 00000000..0fcc0e72 --- /dev/null +++ b/sample_packages/sample_python_package/src/__init__.py @@ -0,0 +1,8 @@ +import sys +import os +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +sys.path.append(SCRIPT_DIR) + +from example import * + +send_https_post_request("__init__.py") diff --git a/sample_packages/sample_python_package/src/example.py b/sample_packages/sample_python_package/src/example.py new file mode 100755 index 00000000..8c59e892 --- /dev/null +++ b/sample_packages/sample_python_package/src/example.py @@ -0,0 +1,19 @@ +import http.client +import json + +# Sends an HTTPS post request and prints out the response. +def send_https_post_request(location: str) -> None: + host = "www.httpbin.org" + conn = http.client.HTTPSConnection(host) + data = {'text': 'Sending data through HTTPS from: ' + location} + json_data = json.dumps(data) + conn.request("POST", "/post", json_data, headers={"Host": host}) + response = conn.getresponse() + print(response.read().decode()) + +def main(): + send_https_post_request("main function") + + +if __name__ == "__main__": + main()