Skip to content

Commit 47517f0

Browse files
Add repo owner tracking (#243)
* Add tracking of Github repository owner to the DirectLinking API calls. * Resolved iterable error on missing extension rules
1 parent c5795c0 commit 47517f0

File tree

6 files changed

+30
-8
lines changed

6 files changed

+30
-8
lines changed

directLinking.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,22 @@ const API_URL_PATH = '/api/v1/trial';
77
const PARTNER_ID = 'github-sarif-action';
88

99
async function getTrainingData(mappingListId, mappingKey, languageKey) {
10+
11+
// create an list of values to populate into the Id param of the DI linking API
12+
let idValue = [PARTNER_ID];
13+
if (process.env.GITHUB_REPOSITORY) {
14+
const githubOwner = process.env.GITHUB_REPOSITORY.split('/')[0];
15+
idValue.push(githubOwner);
16+
}
17+
1018
let url;
1119
if (languageKey) {
12-
url = `${API_URL_ORIGIN}${API_URL_PATH}?Id=${PARTNER_ID}&MappingList=${mappingListId}&MappingKey=${mappingKey}&LanguageKey=${languageKey}`;
20+
url = `${API_URL_ORIGIN}${API_URL_PATH}?Id=${idValue.join(':')}&MappingList=${mappingListId}&MappingKey=${mappingKey}&LanguageKey=${languageKey}`;
1321
}
1422
else {
15-
url = `${API_URL_ORIGIN}${API_URL_PATH}?Id=${PARTNER_ID}&MappingList=${mappingListId}&MappingKey=${mappingKey}`;
23+
url = `${API_URL_ORIGIN}${API_URL_PATH}?Id=${idValue.join(':')}&MappingList=${mappingListId}&MappingKey=${mappingKey}`;
1624
}
25+
1726
return fetch(url)
1827
.then(function (response) {
1928
if (!response.ok) {

dist/index.js

Lines changed: 13 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "github-action-add-sarif-contextual-training",
3-
"version": "1.0.6",
3+
"version": "1.0.7",
44
"description": "GitHub Action for adding contextual training material to SARIF files",
55
"main": "index.js",
66
"scripts": {

sarifProcessors/ruleProcessor.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ async function processRun(run, languageKey, triggeredRules) {
9393

9494
if (run && run.tool && run.tool.extensions && run.tool.extensions) {
9595
for (const extension of run.tool.extensions) {
96+
if (!extension.rules || !Array.isArray(extension.rules)) continue;
97+
9698
for (const rule of extension.rules) {
9799
try {
98100
await processRule(rule, languageKey, triggeredRules);

test-resources/expected.sarif

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@
5252
"problem.severity": "error"
5353
},
5454
"help": {
55-
"text": "Non-HTTPS connections can be intercepted by third parties.\n\nBuild your secure coding skills and defend your code:\n\n[CWE 319] Cleartext Transmission of Sensitive Information [What is this? (2min video)](https://media.securecodewarrior.com/v2/module_200_unprotected_transport_of_sensitive_information.mp4)\n\nThe software transmits sensitive or security-critical data in cleartext in a communication channel that can be sniffed by unauthorized actors. [Try this challenge in Secure Code Warrior](https://portal.securecodewarrior.com/?utm_source=partner-integration:github-sarif-action&partner_id=github-sarif-action#/contextual-microlearning/web/itlp/sensitiveinfo)\n\n[CWE 494] Download of Code Without Integrity Check [What is this? (2min video)](https://media.securecodewarrior.com/v2/module_133_using_components_from_untrusted_sources.mp4)\n\nThe product downloads source code or an executable from a remote location and executes the code without sufficiently verifying the origin and integrity of the code. [Try this challenge in Secure Code Warrior](https://portal.securecodewarrior.com/?utm_source=partner-integration:github-sarif-action&partner_id=github-sarif-action#/contextual-microlearning/web/vulncomponents/untrustedsource)\n\n[CWE 829] Inclusion of Functionality from Untrusted Control Sphere [What is this? (2min video)](https://media.securecodewarrior.com/v2/module_133_using_components_from_untrusted_sources.mp4)\n\nThe software imports, requires, or includes executable functionality (such as a library) from a source that is outside of the intended control sphere. [Try this challenge in Secure Code Warrior](https://portal.securecodewarrior.com/?utm_source=partner-integration:github-sarif-action&partner_id=github-sarif-action#/contextual-microlearning/web/vulncomponents/untrustedsource)",
56-
"markdown": "Non-HTTPS connections can be intercepted by third parties.\n\n## Build your secure coding skills and defend your code\n\n#### [CWE 319] Cleartext Transmission of Sensitive Information *[What is this? (2min video)](https://media.securecodewarrior.com/v2/module_200_unprotected_transport_of_sensitive_information.mp4)*\n\n* The software transmits sensitive or security-critical data in cleartext in a communication channel that can be sniffed by unauthorized actors. [Try this challenge in Secure Code Warrior](https://portal.securecodewarrior.com/?utm_source=partner-integration:github-sarif-action&partner_id=github-sarif-action#/contextual-microlearning/web/itlp/sensitiveinfo)\n\n#### [CWE 494] Download of Code Without Integrity Check *[What is this? (2min video)](https://media.securecodewarrior.com/v2/module_133_using_components_from_untrusted_sources.mp4)*\n\n* The product downloads source code or an executable from a remote location and executes the code without sufficiently verifying the origin and integrity of the code. [Try this challenge in Secure Code Warrior](https://portal.securecodewarrior.com/?utm_source=partner-integration:github-sarif-action&partner_id=github-sarif-action#/contextual-microlearning/web/vulncomponents/untrustedsource)\n\n#### [CWE 829] Inclusion of Functionality from Untrusted Control Sphere *[What is this? (2min video)](https://media.securecodewarrior.com/v2/module_133_using_components_from_untrusted_sources.mp4)*\n\n* The software imports, requires, or includes executable functionality (such as a library) from a source that is outside of the intended control sphere. [Try this challenge in Secure Code Warrior](https://portal.securecodewarrior.com/?utm_source=partner-integration:github-sarif-action&partner_id=github-sarif-action#/contextual-microlearning/web/vulncomponents/untrustedsource)"
55+
"text": "Non-HTTPS connections can be intercepted by third parties.\n\nBuild your secure coding skills and defend your code:\n\n[CWE 319] Cleartext Transmission of Sensitive Information [What is this? (2min video)](https://media.securecodewarrior.com/v2/module_200_unprotected_transport_of_sensitive_information.mp4)\n\nThe software transmits sensitive or security-critical data in cleartext in a communication channel that can be sniffed by unauthorized actors. [Try this challenge in Secure Code Warrior](https://portal.securecodewarrior.com/?utm_source=partner-integration:github-sarif-action:scw&partner_id=github-sarif-action:scw#/contextual-microlearning/web/itlp/sensitiveinfo)\n\n[CWE 494] Download of Code Without Integrity Check [What is this? (2min video)](https://media.securecodewarrior.com/v2/module_133_using_components_from_untrusted_sources.mp4)\n\nThe product downloads source code or an executable from a remote location and executes the code without sufficiently verifying the origin and integrity of the code. [Try this challenge in Secure Code Warrior](https://portal.securecodewarrior.com/?utm_source=partner-integration:github-sarif-action:scw&partner_id=github-sarif-action:scw#/contextual-microlearning/web/vulncomponents/untrustedsource)\n\n[CWE 829] Inclusion of Functionality from Untrusted Control Sphere [What is this? (2min video)](https://media.securecodewarrior.com/v2/module_133_using_components_from_untrusted_sources.mp4)\n\nThe software imports, requires, or includes executable functionality (such as a library) from a source that is outside of the intended control sphere. [Try this challenge in Secure Code Warrior](https://portal.securecodewarrior.com/?utm_source=partner-integration:github-sarif-action:scw&partner_id=github-sarif-action:scw#/contextual-microlearning/web/vulncomponents/untrustedsource)",
56+
"markdown": "Non-HTTPS connections can be intercepted by third parties.\n\n## Build your secure coding skills and defend your code\n\n#### [CWE 319] Cleartext Transmission of Sensitive Information *[What is this? (2min video)](https://media.securecodewarrior.com/v2/module_200_unprotected_transport_of_sensitive_information.mp4)*\n\n* The software transmits sensitive or security-critical data in cleartext in a communication channel that can be sniffed by unauthorized actors. [Try this challenge in Secure Code Warrior](https://portal.securecodewarrior.com/?utm_source=partner-integration:github-sarif-action:scw&partner_id=github-sarif-action:scw#/contextual-microlearning/web/itlp/sensitiveinfo)\n\n#### [CWE 494] Download of Code Without Integrity Check *[What is this? (2min video)](https://media.securecodewarrior.com/v2/module_133_using_components_from_untrusted_sources.mp4)*\n\n* The product downloads source code or an executable from a remote location and executes the code without sufficiently verifying the origin and integrity of the code. [Try this challenge in Secure Code Warrior](https://portal.securecodewarrior.com/?utm_source=partner-integration:github-sarif-action:scw&partner_id=github-sarif-action:scw#/contextual-microlearning/web/vulncomponents/untrustedsource)\n\n#### [CWE 829] Inclusion of Functionality from Untrusted Control Sphere *[What is this? (2min video)](https://media.securecodewarrior.com/v2/module_133_using_components_from_untrusted_sources.mp4)*\n\n* The software imports, requires, or includes executable functionality (such as a library) from a source that is outside of the intended control sphere. [Try this challenge in Secure Code Warrior](https://portal.securecodewarrior.com/?utm_source=partner-integration:github-sarif-action:scw&partner_id=github-sarif-action:scw#/contextual-microlearning/web/vulncomponents/untrustedsource)"
5757
}
5858
},
5959
{

0 commit comments

Comments
 (0)