Skip to content

Commit d066271

Browse files
authored
Merge pull request #54 from GitHubSecurityLab/kevin_advisory
Add advisory support
2 parents 7a0a5d8 + 94cd6f3 commit d066271

File tree

8 files changed

+96
-16
lines changed

8 files changed

+96
-16
lines changed

scripts/audit/run_audit.sh

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,37 @@
44

55
set -e
66

7+
USE_ADVISORY=false
8+
9+
# Parse flags
10+
while [[ "$1" == --* ]]; do
11+
case "$1" in
12+
--advisory)
13+
USE_ADVISORY=true
14+
shift
15+
;;
16+
*)
17+
echo "Unknown option: $1"
18+
exit 1
19+
;;
20+
esac
21+
done
22+
723
if [ -z "$1" ]; then
8-
echo "Usage: $0 <repo>";
24+
echo "Usage: $0 [--advisory] <repo>";
925
exit 1;
1026
fi
1127

1228
python -m seclab_taskflow_agent -t seclab_taskflows.taskflows.audit.fetch_source_code -g repo="$1"
1329
python -m seclab_taskflow_agent -t seclab_taskflows.taskflows.audit.identify_applications -g repo="$1"
1430
python -m seclab_taskflow_agent -t seclab_taskflows.taskflows.audit.gather_web_entry_point_info -g repo="$1"
15-
python -m seclab_taskflow_agent -t seclab_taskflows.taskflows.audit.classify_application_local -g repo="$1"
16-
python -m seclab_taskflow_agent -t seclab_taskflows.taskflows.audit.audit_issue_local_iter -g repo="$1"
31+
32+
if [ "$USE_ADVISORY" = true ]; then
33+
python -m seclab_taskflow_agent -t seclab_taskflows.taskflows.audit.fetch_security_advisories -g repo="$1"
34+
fi
35+
36+
python -m seclab_taskflow_agent -t seclab_taskflows.taskflows.audit.classify_application_local -g repo="$1" -g use_advisory="$USE_ADVISORY"
37+
python -m seclab_taskflow_agent -t seclab_taskflows.taskflows.audit.audit_issue_local_iter -g repo="$1" -g use_advisory="$USE_ADVISORY"
1738

1839
set +e
1940

scripts/audit/run_audit_in_docker.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
# https://stackoverflow.com/a/53122736
66
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
77

8-
${__dir}/../run_in_docker.sh ${__dir}/run_audit.sh "$1"
8+
${__dir}/../run_in_docker.sh ${__dir}/run_audit.sh "$@"

src/seclab_taskflows/personalities/web_application_security_expert.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ toolboxes:
2020
- seclab_taskflow_agent.toolboxes.memcache
2121
- seclab_taskflows.toolboxes.gh_file_viewer
2222
- seclab_taskflow_agent.toolboxes.codeql
23+
- seclab_taskflows.toolboxes.ghsa
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# SPDX-FileCopyrightText: GitHub, Inc.
2+
# SPDX-License-Identifier: MIT
3+
4+
seclab-taskflow-agent:
5+
filetype: prompt
6+
version: "1.0"
7+
prompt: |
8+
## Known Security Advisories for this Repository
9+
10+
Fetch the security advisories for {{ globals.repo }} from memcache (stored under the key 'security_advisories_{{ globals.repo }}'). If the value in the memcache is null or an error message, clearly state that no advisories are available and skip advisory analysis. Otherwise, state how many advisories were found.
11+
Review these advisories and consider them when identifying security risks. If you identify code that is similar to a known advisory pattern, highlight that connection.

src/seclab_taskflows/taskflows/audit/audit_issue_local_iter.yaml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ model_config: seclab_taskflows.configs.model_config
88

99
globals:
1010
repo:
11+
use_advisory:
1112
# Taskflow to audit some potential issues.
1213
taskflow:
1314
- task:
@@ -17,7 +18,7 @@ taskflow:
1718
- seclab_taskflow_agent.personalities.assistant
1819
model: general_tasks
1920
user_prompt: |
20-
Fetch the component issues in {{ globals.repo }}.
21+
Fetch all component issues for the repo {{ globals.repo }} using the get_component_issues_for_repo tool.
2122
toolboxes:
2223
- seclab_taskflows.toolboxes.repo_context
2324
- task:
@@ -29,20 +30,24 @@ taskflow:
2930
- seclab_taskflows.personalities.web_application_security_expert
3031
model: code_analysis
3132
user_prompt: |
32-
The issue is in repo {{ result.repo }} with id {{ result.issue_id }}. The component is under the directory
33+
The issue is in repo {{ result.repo }} with id {{ result.issue_id }}. The component is under the directory
3334
{{ result.location }} with component_id {{ result.component_id }}. The notes of the component is:
3435
3536
{{ result.component_notes }}
3637
37-
You should use this to understand the intended purpose of the component and take it into account when
38+
You should use this to understand the intended purpose of the component and take it into account when
3839
you audit the issue.
3940
4041
The type of the issue is {{ result.issue_type }} and here is the notes of the issue:
4142
4243
{{ result.issue_notes }}
4344
45+
{% if globals.use_advisory == 'true' %}
46+
{% include 'seclab_taskflows.prompts.audit.known_security_advisories' %}
47+
{% endif %}
48+
4449
{% include 'seclab_taskflows.prompts.audit.audit_issue' %}
4550
toolboxes:
4651
- seclab_taskflows.toolboxes.repo_context
4752
- seclab_taskflows.toolboxes.local_file_viewer
48-
53+
- seclab_taskflow_agent.toolboxes.memcache

src/seclab_taskflows/taskflows/audit/classify_application_local.yaml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ model_config: seclab_taskflows.configs.model_config
88

99
globals:
1010
repo:
11+
use_advisory:
1112
# Taskflow to analyze the general contextual information of a project and classify the different applications within it
1213
taskflow:
1314
- task:
@@ -36,8 +37,12 @@ taskflow:
3637
Fetch the entry points and web entry points of the component, then the user actions of this component.
3738
Based on the entry points, web entry points, components, user actions and README.md and if available, SECURITY.md in the {{ globals.repo }},
3839
can you tell me what type of application this repo is and what kind of security boundary it has.
39-
Based on this, determine whether the component is likely to have security problems.
40-
40+
Based on this, determine whether the component is likely to have security problems.
41+
42+
{% if globals.use_advisory == 'true' %}
43+
{% include 'seclab_taskflows.prompts.audit.known_security_advisories' %}
44+
{% endif %}
45+
4146
Identify the most likely security problems in the component. Your task is not to carry out a full audit, but to
4247
identify the main risk in the component so that further analysis can be carried out.
4348
Do not be too specific about an issue, but rather craft your report based on the general functionality and type of
@@ -50,7 +55,7 @@ taskflow:
5055
- Is this component likely to take untrusted user input? For example, remote web requests or IPC, RPC calls?
5156
- What is the intended purpose of this component and its functionality? Does it allow high privileged actions?
5257
Is it intended to provide such functionalities for all users? Or is there complex access control logic involved?
53-
- The component itself may also have its own `README.md` (or a subdirectory of it may have a `README.md`). Take
58+
- The component itself may also have its own `README.md` (or a subdirectory of it may have a `README.md`). Take
5459
a look at those files to help understand the functionality of the component.
5560
5661
For example, an Admin UI/dashboard may be susceptible to client side Javascript vulnerabilities such as XSS, CSRF.
@@ -60,7 +65,7 @@ taskflow:
6065
a web frontend may allow users to access their own content and admins to access all content, but users should not
6166
be able to access another users' content in general.
6267
63-
We're looking for more concrete and serious security issues that affects system integrity or
68+
We're looking for more concrete and serious security issues that affects system integrity or
6469
lead to information leak, so please do not include issues like brute force, Dos, log injection etc.
6570
6671
Also do not include issues that require the system to be already compromised, such as issues that rely on malicious
@@ -72,9 +77,9 @@ taskflow:
7277
Your task is to identify risk rather than properly audit and find security issues. Do not look too much into
7378
the implementation or scrutinize the security measures such as access control and sanitizers at this stage.
7479
Instead, report more general risks that are associated with the type of component
75-
that you are looking at.
80+
that you are looking at.
7681
77-
It is not your task to audit the security measures, but rather just to identify the risks and suggest some issues
82+
It is not your task to audit the security measures, but rather just to identify the risks and suggest some issues
7883
that is worth auditing.
7984
8085
Reflect on your notes and check that the attack scenario meets the above requirements. Exclude low severity issues or
@@ -84,4 +89,5 @@ taskflow:
8489
If you think the issues satisfy the criteria, store a component issue entry for each type of issue identified.
8590
toolboxes:
8691
- seclab_taskflows.toolboxes.repo_context
87-
- seclab_taskflows.toolboxes.local_file_viewer
92+
- seclab_taskflows.toolboxes.local_file_viewer
93+
- seclab_taskflow_agent.toolboxes.memcache
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# SPDX-FileCopyrightText: GitHub, Inc.
2+
# SPDX-License-Identifier: MIT
3+
4+
seclab-taskflow-agent:
5+
filetype: taskflow
6+
version: "1.0"
7+
8+
model_config: seclab_taskflows.configs.model_config
9+
10+
globals:
11+
repo:
12+
13+
# Example taskflow to fetch and review security advisories for a repository
14+
taskflow:
15+
- task:
16+
must_complete: true
17+
exclude_from_context: false
18+
agents:
19+
- seclab_taskflow_agent.personalities.assistant
20+
model: general_tasks
21+
user_prompt: |
22+
Fetch all GitHub Security Advisories (GHSAs) for the repo {{ globals.repo }}.
23+
24+
If an error occurs during fetching, store the error message in memcache under the key 'security_advisories_{{ globals.repo }}'.
25+
Ensure the error message starts with "Error:" followed by a description of the error.
26+
27+
If fetching is successful, store the list of advisories in memcache under the key 'security_advisories_{{ globals.repo }}'.
28+
29+
If one or more advisories are found, provide a summary of the findings including:
30+
1. How many advisories were found
31+
2. The severity levels of the advisories
32+
toolboxes:
33+
- seclab_taskflows.toolboxes.ghsa
34+
- seclab_taskflow_agent.toolboxes.memcache
35+
- seclab_taskflows.toolboxes.local_file_viewer
36+
- seclab_taskflows.toolboxes.gh_file_viewer

src/seclab_taskflows/taskflows/audit/filter_severity.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: 2025 GitHub
1+
# SPDX-FileCopyrightText: GitHub, Inc.
22
# SPDX-License-Identifier: MIT
33

44
seclab-taskflow-agent:

0 commit comments

Comments
 (0)