2013년 12월 17일 화요일

[Python] Where file search utility

This utility searches all the paths in a semi-colon delimited environment variable list for files matching a given filespec. By default, PATH is used for the enviroment. For example, on my computer

C:\>where note*.exe
C:\WINNT\system32\notepad.exe
C:\WINNT\NOTEPAD.EXE


소스코드:

"""Searches a path for a specified file.
"""

__author__ = "Bill McNeill <billmcn@speakeasy.net>"
__version__ = "1.0"

import sys
import os
import os.path
import glob

def help():
        print """\
where (Environment) Filespec

Searches the paths specified in Environment for all files matching Filespec.
If Environment is not specified, the system PATH is used.\
"""

if len(sys.argv) == 3:
        paths = os.environ[sys.argv[1]]
        file = sys.argv[2]
elif len(sys.argv) == 2:
        paths = os.environ["PATH"]
        file = sys.argv[1]
else:
        help()
        sys.exit(0)

for path in paths.split(";"):
        for match in glob.glob(os.path.join(path, file)):
                print match

홈페이지 jQuery 라이브러리에서 CVE-2019-11358 취약점 패치 여부 확인 방법

현재 홈페이지에서 사용 중인 jQuery 라이브러리가 CVE-2019-11358 취약점 패치를 적용했는지 확인하는 방법은 다음과 같습니다. 1. jQuery 버전 확인 홈페이지 소스 코드를 확인하여 jQuery 라이브러리 버전을 직접 확인합니다. 웹 ...