Skip to content

Commit

Permalink
Merge pull request #1 from owaspsamm/develop
Browse files Browse the repository at this point in the history
GitHub Actions Bugfixes
  • Loading branch information
itscooper authored Dec 4, 2023
2 parents 4538bd4 + 06c1b38 commit 473db42
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
15 changes: 9 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@
FROM python:3.8-slim

# Set the working directory in the container
WORKDIR /usr/src/app
WORKDIR /github/workspace

# Copy the script and the templates directory into the container
COPY markmysamm.py ./
COPY templates/ ./templates/
COPY requirements.txt /requirements.txt
COPY markmysamm.py /markmysamm.py
COPY templates/ /templates/
RUN ls -la

# Install any needed packages specified in requirements.txt
# You should create a requirements.txt file if you have external dependencies
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install --no-cache-dir -r /requirements.txt

# Run markmysamm.py when the container launches
ENTRYPOINT ["python3", "markmysamm.py"]
#ENTRYPOINT ["python3", "/markmysamm.py"]
# Temporarily replace the entrypoint for debugging
ENTRYPOINT ["sh", "-c", "echo Current directory: $(pwd) && echo Directory contents: $(ls -la) && echo fr contents: $(ls -la fr) && python3 /markmysamm.py $0 $@"]
6 changes: 2 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,5 @@ runs:
using: 'docker'
image: 'Dockerfile'
args:
- '-i'
- ${{ inputs.input_directory }}
- '-o'
- ${{ inputs.output_directory }}
- '-i ${{ inputs.input_directory }}'
- '-o ${{ inputs.output_directory }}'
19 changes: 11 additions & 8 deletions markmysamm.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ def process_template_content(input_file, variables):
"""
Reads a Markdown template file, replaces placeholders with actual values, and returns content.
:param input_file: path to the input template file
:param input_file: path to the input template file. Relative to this script's location
:param variables: a dictionary where keys are placeholder names and values are the actual values
"""
with open(input_file, 'r') as file:
with open(os.path.dirname(os.path.abspath(__file__)) + input_file, 'r') as file:
template = file.read()

return template.format(**variables)
Expand All @@ -80,8 +80,8 @@ def process_template(input_file, output_file, variables):
"""
Reads a Markdown template file, replaces placeholders with actual values, and writes to a new file.
:param input_file: path to the input template file
:param output_file: path to the output file
:param input_file: path to the input template file (relative to this script's location)
:param output_file: path to the output file (relative to working directory)
:param variables: a dictionary where keys are placeholder names and values are the actual values
"""
print('[+] Writing file: '+output_file)
Expand Down Expand Up @@ -300,10 +300,13 @@ def fix_bool(variable):
criteria += '- '+critvalue+'\n'
# Now get answer set
answer_set_markdown = ''
for asetkey,asetvalue in nested_dict['answer_sets'].items():
if asetvalue['id'] == answer_set_id:
for ansvalue in asetvalue['values']:
answer_set_markdown += '- '+fix_bool(ansvalue['text'])+'\n'
try:
for asetkey,asetvalue in nested_dict['answer_sets'].items():
if asetvalue['id'] == answer_set_id:
for ansvalue in asetvalue['values']:
answer_set_markdown += '- '+fix_bool(ansvalue['text'])+'\n'
except Exception as err:
print("Error handling answer sets: ", err)

# Set variables for the stream level template
variables = {
Expand Down

0 comments on commit 473db42

Please sign in to comment.