Skip to content

Commit

Permalink
Merge pull request #4 from kaje11/rng_update
Browse files Browse the repository at this point in the history
Fixed HTML templating bug & Image width issue
  • Loading branch information
hvqzao authored Jan 21, 2021
2 parents 3b4b2ff + 25d37e4 commit 08485d7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
7 changes: 3 additions & 4 deletions src/openxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ def xl(self, children):
self._insert(e)
return e

def picture(self, filename, name='', descr='', cap=627):
def picture(self, filename, name='', descr='', cap=None):
# ext, content_type, relationships
ext = filename.split('.')[-1]
if ext == 'jpg':
Expand Down Expand Up @@ -618,9 +618,8 @@ def picture(self, filename, name='', descr='', cap=627):
im = Image.open(filename)
x, y = im.size
if cap != None:
if x > cap:
y = int(round(float(cap * y) / x))
x = cap
y = int(round(float(cap * y) / x))
x = cap
x = str(x * 9525)
y = str(y * 9525)
e = etree.fromstring('''
Expand Down
13 changes: 5 additions & 8 deletions src/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ class ns:
#__vulnparam_highlighting = True
#__truncate = True
_pPr_annotation = False
chartIterator = 0

def __init__(self):
self._meta_init()
Expand Down Expand Up @@ -872,20 +871,18 @@ def _xml_apply_chart(self, chart_struct, values):
chart_rid = chart.attrib['{%s}id' % self.ns.r]

# iterator used for identifying copies of charts
self.chartIterator += 1
chartNewId = chart_rid + 'copy' + str(self.chartIterator)

chart.attrib['{%s}id' % self.ns.r] = chartNewId
newId = self._openxml.new_rel_id()
chart.attrib['{%s}id' % self.ns.r] = "rId" + str(newId)

# charts/chart.xml
chart_rel = filter(lambda x: x.attrib['Id'] == chart_rid and x.attrib[
'Type'] == 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart',
etree.ETXPath('//{%s}Relationship' % self.ns.a)(self._xml))[0]

chart_rel_target = chart_rel.attrib['Target']
chart_rel_targetCopy = 'copy' + str(self.chartIterator) + chart_rel_target
chart_rel_targetCopy = 'copy' + str(newId) + chart_rel_target
chart_relCopy = copy.deepcopy(chart_rel)
chart_relCopy.attrib['Id'] = chartNewId
chart_relCopy.attrib['Id'] = "rId" + str(newId)
chart_relCopy.attrib['Target'] = chart_rel_targetCopy
chart_relParent = chart_rel.getparent()
chart_relParent.append(chart_relCopy)
Expand Down Expand Up @@ -918,7 +915,7 @@ def _xml_apply_chart(self, chart_struct, values):
def copyRelPackages(relationship):
# the original drawing name used for the chart
relationshipName = relationship.attrib["Target"]
relationshipCopyName = relationshipName.replace("../", "../copy" + str(self.chartIterator))
relationshipCopyName = relationshipName.replace("../", "../copy" + str(newId))
relationship.attrib["Target"] = relationshipCopyName

pkgName = relationshipName.replace("../", "/word/")
Expand Down
10 changes: 8 additions & 2 deletions src/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,16 @@ class Version(object):
Generate reports based on HP WebInspect, BurpSuite Pro scans,
own custom data, knowledge base and Microsoft Office Word templates.
'''
version = '1.0.3'
date = 'Tuesday Jan 12 11:00:00 2021'
version = '1.0.5'
date = 'Wed Jan 20 13:38:46 2021'
changelog = '''
''' + version + ''' - ''' + date + '''
- Fixed images not resizing for width exceeding the inital size
1.0.4 - Tue Jan 19 20:42:36 2021
- Fixed HTML support
1.0.3 - Tuesday Jan 12 11:00:00 2021
- Nmap scan support for multiple XML files - gets enabled if 'OpenPorts' directive is found in the template
- FIX: Fixed deprecated functions e.g. icon/OnFileDrop handling
- Added support for multiple charts in the _xml_apply_chart functions via objects cloning
Expand Down

0 comments on commit 08485d7

Please sign in to comment.