Skip to content

⚠️ CONFLICT! Lineage pull request for: skeleton #31

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

Draft
wants to merge 12 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,16 +201,23 @@ jobs:
uses: mxschmitt/action-tmate@v3
if: env.RUN_TMATE
test:
name: test source - py${{ matrix.python-version }}
name: test source - py${{ matrix.python-version }} - ${{ matrix.platform }}
needs:
- diagnostics
permissions:
# actions/checkout needs this to fetch code
contents: read
runs-on: ubuntu-latest
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
# We test on all of the latest platforms available to use with GitHub-
# hosted runners for public repositories.
platform:
- macos-latest
- ubuntu-24.04-arm
- ubuntu-latest
- windows-latest
python-version:
- "3.9"
- "3.10"
Expand Down Expand Up @@ -251,7 +258,8 @@ jobs:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v4
env:
BASE_CACHE_KEY: ${{ github.job }}-${{ runner.os }}-\
BASE_CACHE_KEY: ${{ github.job }}-\
${{ runner.os }}-${{ runner.arch }}-\
py${{ steps.setup-python.outputs.python-version }}-
with:
path: ${{ env.PIP_CACHE_DIR }}
Expand Down Expand Up @@ -404,17 +412,24 @@ jobs:
uses: mxschmitt/action-tmate@v3
if: env.RUN_TMATE
test-build:
name: test built wheel - py${{ matrix.python-version }}
name: test built wheel - py${{ matrix.python-version }} - ${{ matrix.platform }}
needs:
- diagnostics
- build
permissions:
# actions/checkout needs this to fetch code
contents: read
runs-on: ubuntu-latest
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
# We test on all of the latest platforms available to use with GitHub-
# hosted runners for public repositories.
platform:
- macos-latest
- ubuntu-24.04-arm
- ubuntu-latest
- windows-latest
python-version:
- "3.9"
- "3.10"
Expand Down Expand Up @@ -455,7 +470,8 @@ jobs:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v4
env:
BASE_CACHE_KEY: ${{ github.job }}-${{ runner.os }}-\
BASE_CACHE_KEY: ${{ github.job }}-\
${{ runner.os }}-${{ runner.arch }}-\
py${{ steps.setup-python.outputs.python-version }}-
with:
path: ${{ env.PIP_CACHE_DIR }}
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ repos:

# Ansible hooks
- repo: https://github.com/ansible/ansible-lint
rev: v25.1.3
rev: v25.4.0
hooks:
- id: ansible-lint
additional_dependencies:
Expand Down
104 changes: 104 additions & 0 deletions src/example/example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
"""example is an example Python library and tool.

Divide one integer by another and log the result. Also log some information
from an environment variable and a package resource.

EXIT STATUS
This utility exits with one of the following values:
0 Calculation completed successfully.
>0 An error occurred.

Usage:
example [--log-level=LEVEL] <dividend> <divisor>
example (-h | --help)

Options:
-h --help Show this message.
--log-level=LEVEL If specified, then the log level will be set to
the specified value. Valid values are "debug", "info",
"warning", "error", and "critical". [default: info]
"""

# Standard Python Libraries
from importlib.resources import files
import logging
import os
import sys
from typing import Any, Dict

# Third-Party Libraries
import docopt

# There are no type stubs for the schema library, so mypy requires the type:
# ignore hint.
from schema import And, Schema, SchemaError, Use # type: ignore

from ._version import __version__

DEFAULT_ECHO_MESSAGE: str = "Hello World from the example default!"


def example_div(dividend: int, divisor: int) -> float:
"""Print some logging messages."""
logging.debug("This is a debug message")
logging.info("This is an info message")
logging.warning("This is a warning message")
logging.error("This is an error message")
logging.critical("This is a critical message")
return dividend / divisor


def main() -> None:
"""Set up logging and call the example function."""
args: Dict[str, str] = docopt.docopt(__doc__, version=__version__)
# Validate and convert arguments as needed
schema: Schema = Schema(
{
"--log-level": And(
str,
Use(str.lower),
lambda n: n in ("debug", "info", "warning", "error", "critical"),
error="Possible values for --log-level are "
+ "debug, info, warning, error, and critical.",
),
"<dividend>": Use(int, error="<dividend> must be an integer."),
"<divisor>": And(
Use(int),
lambda n: n != 0,
error="<divisor> must be an integer that is not 0.",
),
str: object, # Don't care about other keys, if any
}
)

try:
validated_args: Dict[str, Any] = schema.validate(args)
except SchemaError as err:
# Exit because one or more of the arguments were invalid
print(err, file=sys.stderr)
sys.exit(1)

# Assign validated arguments to variables
dividend: int = validated_args["<dividend>"]
divisor: int = validated_args["<divisor>"]
log_level: str = validated_args["--log-level"]

# Set up logging
logging.basicConfig(
format="%(asctime)-15s %(levelname)s %(message)s", level=log_level.upper()
)

logging.info("%d / %d == %f", dividend, divisor, example_div(dividend, divisor))

# Access some data from an environment variable
message: str = os.getenv("ECHO_MESSAGE", DEFAULT_ECHO_MESSAGE)
logging.info('ECHO_MESSAGE="%s"', message)

# Access some data from our package data (see the setup.py)
secret_message: str = (
files(__package__).joinpath("data", "secret.txt").read_text().strip()
)
logging.info('Secret="%s"', secret_message)

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High

This expression logs
sensitive data (secret)
as clear text.

Copilot Autofix

AI about 1 month ago

To fix the issue, we should avoid logging the sensitive data in clear text. Instead, we can log a generic message indicating that the secret was accessed without revealing its content. Alternatively, if logging the content is necessary for debugging purposes, we can mask or redact the sensitive parts of the data before logging. For this fix, we will log a generic message to ensure no sensitive information is exposed.


Suggested changeset 1
src/example/example.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/example/example.py b/src/example/example.py
--- a/src/example/example.py
+++ b/src/example/example.py
@@ -100,3 +100,3 @@
     )
-    logging.info('Secret="%s"', secret_message)
+    logging.info("Secret accessed successfully.")
 
EOF
@@ -100,3 +100,3 @@
)
logging.info('Secret="%s"', secret_message)
logging.info("Secret accessed successfully.")

Copilot is powered by AI and may make mistakes. Always verify output.

# Stop logging and clean up
logging.shutdown()
4 changes: 4 additions & 0 deletions src/lcgit/_version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""This file defines the version of this module."""

<<<<<<< HEAD:src/lcgit/_version.py
__version__ = "2.0.0"
=======
__version__ = "0.2.2"
>>>>>>> b122bbddb6b6be656c655a1049d88bbdf12f940a:src/example/_version.py
Loading