[helper] Add a check for valid project name when generating files.

This commit is contained in:
Oliver Chang 2017-05-12 15:58:13 -07:00
parent c4054c4d8e
commit f576b352b4
1 changed files with 6 additions and 0 deletions

View File

@ -40,6 +40,8 @@ BASE_IMAGES = [
'gcr.io/oss-fuzz-base/base-runner-debug',
]
VALID_PROJECT_NAME_REGEX = re.compile(r'^[a-zA-Z0-9_-]+$')
def main():
os.chdir(OSSFUZZ_DIR)
@ -410,6 +412,10 @@ def reproduce(args):
def generate(args):
"""Generate empty project files."""
if not VALID_PROJECT_NAME_REGEX.match(args.project_name):
print('Invalid project name.', file=sys.stderr)
return 1
dir = os.path.join('projects', args.project_name)
try: