Skip to main content

A Python module that executes a callback script if a password is not entered within a specified time interval

Project description

Failsafe

A Python module that executes a callback script if a password is not entered within a specified time interval. This security feature acts as a failsafe mechanism to protect sensitive systems and data.

Features

  • Configurable timeout period
  • Thread-based asynchronous execution
  • Customizable callback script
  • Password verification system
  • Logging functionality

Requirements

  • Python 3.6 or higher
  • No external dependencies required

Files

  • failsafe.py: Core module implementing the failsafe timer functionality
  • example.py: Example implementation showing how to use the failsafe module
  • callback_script.py: Example callback script that logs failsafe trigger events

Installation

No installation required. Simply copy the files to your project directory.

Usage

  1. Import the FailSafe class:
from failsafe import FailSafe
  1. Create a failsafe timer instance:
timer = FailSafe(timeout_seconds=300, callback_script='your_callback_script.py')
  1. Start the failsafe timer:
timer.start()
  1. Update the timer when correct password is entered:
timer.update_password_time()
  1. Stop the failsafe timer when done:
timer.stop()

Example

from failsafe import FailSafe

# Create failsafe timer with 5 minutes timeout
timer = FailSafe(timeout_seconds=300, callback_script='callback_script.py')
timer.start()

# Get password input
password = input("Enter password: ")
if password == "correct_password":
    timer.update_password_time()

Callback Script

The failsafe callback script is executed when the password timeout occurs. You can customize the callback script to perform various security actions such as:

  • System logout
  • Screen lock
  • Send security notifications
  • Log security events
  • Execute emergency security measures

Example failsafe callback script:

from datetime import datetime

def main():
    log_file = "failsafe_timeout.log"
    current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    
    with open(log_file, "a") as f:
        f.write(f"[{current_time}] Failsafe callback script executed due to password timeout.\n")

if __name__ == "__main__":
    main()

Security Considerations

  1. Implement proper password validation in your application
  2. Secure the failsafe callback script to prevent unauthorized access
  3. Consider encrypting sensitive data in logs
  4. Implement appropriate error handling
  5. Use secure methods for password storage and verification
  6. Regularly test the failsafe mechanism to ensure it works as expected

Contributing

Feel free to submit issues and enhancement requests to improve the failsafe mechanism.

License

This project is open source and available under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

failsafe-0.1.0.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

failsafe-0.1.0-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file failsafe-0.1.0.tar.gz.

File metadata

  • Download URL: failsafe-0.1.0.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.6

File hashes

Hashes for failsafe-0.1.0.tar.gz
Algorithm Hash digest
SHA256 743807e9e84df8dcb7b9f7bb89228b2e10a075c347b023e007d791b9c6cf824a
MD5 a7b231ed8acad819318d437d25d8a359
BLAKE2b-256 84e5861a28b10ed1057fc0673c9a52f6ba0ce7a03a7238bc089e1831f24786cc

See more details on using hashes here.

File details

Details for the file failsafe-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: failsafe-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.6

File hashes

Hashes for failsafe-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 edec511bcf6862de13f947f6660f3e7b5e12e163887f6c51c7670ff0d1056fd5
MD5 d07620bef5e809f62bd1817140ebb6b5
BLAKE2b-256 c9942810e0c76adca160fa44ef800e0d9ebc7421cec25521b1c062b20641655b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page