-
Notifications
You must be signed in to change notification settings - Fork 3
⚠️ 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
cisagovbot
wants to merge
12
commits into
develop
Choose a base branch
from
lineage/skeleton
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ab35954
Upgrade to the latest version of the ansible-lint pre-commit hook
jsf9k d2d8236
Merge pull request #210 from cisagov/improvement/upgrade-to-latest-an…
jsf9k d1892d1
Merge https://github.com/cisagov/skeleton-generic into lineage/skeleton
814de27
Merge pull request #152 from cisagov/lineage/skeleton
mcdonnnj 4abc8ab
Test across more platforms
mcdonnnj 7221c7f
Explain platform selection in the `build` workflow
mcdonnnj 5f821e1
Merge pull request #151 from cisagov/improvement/test_on_additional_p…
mcdonnnj 7d33877
Adjust how package data is accessed
mcdonnnj dc51c81
Bump version from 0.2.1 to 0.2.2
mcdonnnj 9bdefe3
Separate the resource path argument to `joinpath`
mcdonnnj b122bbd
Merge pull request #150 from cisagov/improvement/adjust_handling_of_p…
mcdonnnj 2ac878a
Merge https://github.com/cisagov/skeleton-python-library into lineage…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
||
# Stop logging and clean up | ||
logging.shutdown() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check failure
Code scanning / CodeQL
Clear-text logging of sensitive information High
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.