Skip to content

Commit

Permalink
security update
Browse files Browse the repository at this point in the history
  • Loading branch information
jhpyle committed May 4, 2021
1 parent dd8d0fd commit e3dbf6c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## [1.2.65] - 2021-05-04
### Fixed
- Important security vulnerability.

## [1.2.64] - 2021-05-04
### Added
- The `popover trigger` feature.
Expand Down
21 changes: 15 additions & 6 deletions docassemble_base/docassemble/base/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
from unicodedata import normalize
from collections.abc import Iterable
from jinja2.runtime import Undefined
import warnings
TypeType = type(type(None))
locale.setlocale(locale.LC_ALL, '')
contains_volatile = re.compile('^(x\.|x\[|.*\[[ijklmn]\])')
Expand Down Expand Up @@ -3341,9 +3342,18 @@ def qr_code(string, width=None, alt_text=None):
else:
return('[QR ' + string + ', ' + width + ', ' + str(alt_text) + ']')

def pkg_resources_resource_filename(package_or_requirement, resource_name):
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("error")
try:
result = pkg_resources.resource_filename(package_or_requirement, resource_name)
except:
return None
return result

def standard_template_filename(the_file):
try:
return(pkg_resources.resource_filename(pkg_resources.Requirement.parse('docassemble.base'), "docassemble/base/data/templates/" + str(the_file)))
return(pkg_resources_resource_filename(pkg_resources.Requirement.parse('docassemble.base'), "docassemble/base/data/templates/" + str(the_file)))
except:
#logmessage("Error retrieving data file\n")
return(None)
Expand All @@ -3366,14 +3376,13 @@ def package_template_filename(the_file, **kwargs):
if not re.match(r'data/.*', parts[1]):
parts[1] = 'data/templates/' + parts[1]
try:
return(pkg_resources.resource_filename(pkg_resources.Requirement.parse(parts[0]), re.sub(r'\.', r'/', parts[0]) + '/' + parts[1]))
return(pkg_resources_resource_filename(pkg_resources.Requirement.parse(parts[0]), re.sub(r'\.', r'/', parts[0]) + '/' + parts[1]))
except:
return(None)
return(None)

def standard_question_filename(the_file):
return(pkg_resources.resource_filename(pkg_resources.Requirement.parse('docassemble.base'), "docassemble/base/data/questions/" + str(the_file)))
return(None)
return(pkg_resources_resource_filename(pkg_resources.Requirement.parse('docassemble.base'), "docassemble/base/data/questions/" + str(the_file)))

def package_data_filename(the_file):
#logmessage("package_data_filename with: " + str(the_file))
Expand Down Expand Up @@ -3401,7 +3410,7 @@ def package_data_filename(the_file):
return None
return(abs_file.path)
try:
result = pkg_resources.resource_filename(pkg_resources.Requirement.parse(parts[0]), re.sub(r'\.', r'/', parts[0]) + '/' + parts[1])
result = pkg_resources_resource_filename(pkg_resources.Requirement.parse(parts[0]), re.sub(r'\.', r'/', parts[0]) + '/' + parts[1])
except:
result = None
#if result is None or not os.path.isfile(result):
Expand All @@ -3414,7 +3423,7 @@ def package_question_filename(the_file):
if not re.match(r'data/.*', parts[1]):
parts[1] = 'data/questions/' + parts[1]
try:
return(pkg_resources.resource_filename(pkg_resources.Requirement.parse(parts[0]), re.sub(r'\.', r'/', parts[0]) + '/' + parts[1]))
return(pkg_resources_resource_filename(pkg_resources.Requirement.parse(parts[0]), re.sub(r'\.', r'/', parts[0]) + '/' + parts[1]))
except:
return(None)
return(None)
Expand Down
2 changes: 1 addition & 1 deletion docassemble_base/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def find_package_data(where='.', package='', exclude=standard_exclude, exclude_d
"requests-oauthlib==1.3.0",
"requests-toolbelt==0.9.1",
"rfc3986==1.4.0",
"rsa==4.6",
"rsa==4.7",
"ruamel.yaml==0.16.12",
"ruamel.yaml.clib==0.2.2",
"scipy==1.5.4",
Expand Down
2 changes: 1 addition & 1 deletion docassemble_webapp/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def read(fname):
"retry-decorator==1.1.1",
"rfc3339==6.2",
"rfc3986==1.4.0",
"rsa==4.6",
"rsa==4.7",
"ruamel.yaml==0.16.12",
"ruamel.yaml.clib==0.2.2",
"s3transfer==0.3.3",
Expand Down

0 comments on commit e3dbf6c

Please sign in to comment.