Created
          April 1, 2022 12:54 
        
      - 
      
- 
        Save pantsmanuk/5e2f366922214e5b85237a7549fe79d7 to your computer and use it in GitHub Desktop. 
    Patch for sc0tfree/updog to add random password support
  
        
  
    
      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
    
  
  
    
  | Index: updog/__main__.py | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>UTF-8 | |
| =================================================================== | |
| diff --git a/updog/__main__.py b/updog/__main__.py | |
| --- a/updog/__main__.py (revision 28a1ac16122fe520e29f7b21cffe85744771e216) | |
| +++ b/updog/__main__.py (date 1648817380789) | |
| @@ -1,6 +1,8 @@ | |
| import os | |
| import signal | |
| import argparse | |
| +import secrets | |
| +import string | |
| from flask import Flask, render_template, send_file, redirect, request, send_from_directory, url_for, abort | |
| from flask_httpauth import HTTPBasicAuth | |
| @@ -31,7 +33,8 @@ | |
| '[Default=.]') | |
| parser.add_argument('-p', '--port', type=int, default=9090, | |
| help='Port to serve [Default=9090]') | |
| - parser.add_argument('--password', type=str, default='', help='Use a password to access the page. (No username)') | |
| + parser.add_argument('--password', type=str, default='', action='store', nargs='?', | |
| + help='Use a password to access the page. (No username)') | |
| parser.add_argument('--ssl', action='store_true', help='Use an encrypted connection') | |
| parser.add_argument('--version', action='version', version='%(prog)s v'+VERSION) | |
| @@ -151,6 +154,11 @@ | |
| return redirect(request.referrer) | |
| + # If --password argument is supplied without a value, generate and print a random one. | |
| + if args.password is None: | |
| + args.password = ''.join((secrets.choice(string.ascii_letters+string.digits) for _ in range(10))) | |
| + success('Random password: {}'.format(args.password)) | |
| + | |
| # Password functionality is without username | |
| users = { | |
| '': generate_password_hash(args.password) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment