Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ jobs:
- `max-request-in-parallel`: Defines the total HTTP Request that can be done in parallel
- `discovery-enabled`: Defined if the discovery is enabled
- `discovery-orgs`: List of organizations to be includes in the discovery, example: `discovery-orgs: owasp,nodejs`. The OpenSSF Scorecard API is case sensitive, please use the same organization name as in the github url, like: https://github.com/NodeSecure is `NodeSecure` and not `nodesecure`. [See example](https://github.com/NodeSecure/Governance/issues/21#issuecomment-1474770986)
- `report-tags-enabled`: Defines if the markdown report must be created/updated around tags by default is disabled. This is useful if the report is going to be include in a file that has other content on it, like docusaurus docs site or similar.
- `report-start-tag`: Defines the start tag, default `<!-- OPENSSF-SCORECARD-MONITOR:START -->`
- `report-end-tag` Defines the closing tag, default `<!-- OPENSSF-SCORECARD-MONITOR:END -->`

- `report-tags-enabled`: Defines if the markdown report must be created/updated around tags by default is disabled. This is useful if the report is going to be include in a file that has other content on it, like docusaurus docs site or similar
- `report-start-tag` Defines the start tag, default `<!-- OPENSSF-SCORECARD-MONITOR:START -->`
- `report-end-tag`: Defines the closing tag, default `<!-- OPENSSF-SCORECARD-MONITOR:END -->`
- `render-badge`: Defines if the OpenSSF badge must be rendered in the reportor to only show the score

### Outputs

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ inputs:
description: 'Maximum number of HTTP requests to be executed in parallel'
required: false
default: "10"
render-badge:
description: 'Render the OSSF badge in the report'
required: false
default: "false"

outputs:
scores:
Expand Down
17 changes: 9 additions & 8 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27711,7 +27711,7 @@ const generateScope = async ({ octokit, orgs, scope, maxRequestInParallel }) =>
return newScope
}

const generateScores = async ({ scope, database: currentDatabase, maxRequestInParallel, reportTagsEnabled }) => {
const generateScores = async ({ scope, database: currentDatabase, maxRequestInParallel, reportTagsEnabled, renderBadge }) => {
// @TODO: Improve deep clone logic
const database = JSON.parse(JSON.stringify(currentDatabase))
const platform = 'github.com'
Expand Down Expand Up @@ -27770,8 +27770,8 @@ const generateScores = async ({ scope, database: currentDatabase, maxRequestInPa

core.debug('All the scores are already collected')

const reportContent = await generateReportContent(scores, reportTagsEnabled)
const issueContent = await generateIssueContent(scores)
const reportContent = await generateReportContent(scores, reportTagsEnabled, renderBadge)
const issueContent = await generateIssueContent(scores, renderBadge)

// SET OUTPUTS
core.setOutput('scores', scores)
Expand Down Expand Up @@ -27834,20 +27834,20 @@ const saveScore = ({ database, platform, org, repo, score, date, commit }) => {
repoRef.current = { score, date, commit }
}

const generateReportContent = async (scores, reportTagsEnabled) => {
const generateReportContent = async (scores, reportTagsEnabled, renderBadge) => {
core.debug('Generating report content')
const template = await readFile(__nccwpck_require__.ab + "report.ejs", 'utf8')
return ejs.render(template, { scores, reportTagsEnabled })
return ejs.render(template, { scores, reportTagsEnabled, renderBadge })
}

const generateIssueContent = async (scores) => {
const generateIssueContent = async (scores, renderBadge) => {
core.debug('Generating issue content')
const scoresInScope = scores.filter(({ currentDiff }) => currentDiff)
if (!scoresInScope.length) {
return null
}
const template = await readFile(__nccwpck_require__.ab + "issue.ejs", 'utf8')
return ejs.render(template, { scores: scoresInScope })
return ejs.render(template, { scores: scoresInScope, renderBadge })
}

module.exports = {
Expand Down Expand Up @@ -28161,6 +28161,7 @@ async function run () {
const reportTagsEnabled = normalizeBoolean(core.getInput('report-tags-enabled'))
const startTag = core.getInput('report-start-tag') || '<!-- OPENSSF-SCORECARD-MONITOR:START -->'
const endTag = core.getInput('report-end-tag') || '<!-- OPENSSF-SCORECARD-MONITOR:END -->'
const renderBadge = normalizeBoolean(core.getInput('render-badge'))

// Error Handling
if (!githubToken && [autoPush, autoCommit, generateIssue, discoveryEnabled].some(value => value)) {
Expand Down Expand Up @@ -28221,7 +28222,7 @@ async function run () {

// PROCESS
core.info('Generating scores...')
const { reportContent, issueContent, database: newDatabaseState } = await generateScores({ scope, database, maxRequestInParallel, reportTagsEnabled })
const { reportContent, issueContent, database: newDatabaseState } = await generateScores({ scope, database, maxRequestInParallel, reportTagsEnabled, renderBadge })

core.info('Checking database changes...')
const hasChanges = isDifferent(database, newDatabaseState)
Expand Down
2 changes: 1 addition & 1 deletion dist/issue.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ There are changes in the following repositories:
| -- | -- | -- | -- | -- | -- |
<%_ } -%>
<%_ scores.forEach( score => { -%>
| [<%= score.org %>/<%= score.repo %>](https://<%= score.platform %>/<%= score.org %>/<%= score.repo %>) | [<%= score.commit.slice(0, 7) %>](https://<%= score.platform %>/<%= score.org %>/<%= score.repo %>/commit/<%= score.commit %>) | <%= score.score %> | <%= score.currentDiff || 0 %> | [Full Report](https://deps.dev/project/github/<%= score.org.toLowerCase() %>%2F<%= score.repo.toLowerCase() %>) | [Fix it](http://app.stepsecurity.io/securerepo?repo=<%= score.org %>/<%= score.repo %>) |
| [<%= score.org %>/<%= score.repo %>](https://<%= score.platform %>/<%= score.org %>/<%= score.repo %>) | [<%= score.commit.slice(0, 7) %>](https://<%= score.platform %>/<%= score.org %>/<%= score.repo %>/commit/<%= score.commit %>) | <% if (!renderBadge) { -%><%= score.score %> <%_ } -%> <%_ if (renderBadge) { -%> [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/<%= score.org %>/<%= score.repo %>/badge)](https://api.securityscorecards.dev/projects/github.com/<%= score.org %>/<%= score.repo %>) <%_ } -%> | <%= score.currentDiff || 0 %> | [Full Report](https://deps.dev/project/github/<%= score.org.toLowerCase() %>%2F<%= score.repo.toLowerCase() %>) | [Fix it](http://app.stepsecurity.io/securerepo?repo=<%= score.org %>/<%= score.repo %>) |
<%_ }); -%>

_Report generated by [UlisesGascon/openssf-scorecard-monitor](https://github.com/UlisesGascon/openssf-scorecard-monitor)._
2 changes: 1 addition & 1 deletion dist/report.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
| -- | -- | -- | -- | -- | -- | -- |
<%_ } -%>
<%_ scores.forEach( score => { -%>
| [<%= score.org %>/<%= score.repo %>](https://<%= score.platform %>/<%= score.org %>/<%= score.repo %>) | [<%= score.commit.slice(0, 7) %>](https://<%= score.platform %>/<%= score.org %>/<%= score.repo %>/commit/<%= score.commit %>) | <%= score.score %> | <%= score.date %> | <%= score.currentDiff || 0 %> | [Full Report](https://deps.dev/project/github/<%= score.org.toLowerCase() %>%2F<%= score.repo.toLowerCase() %>) | [Fix it](http://app.stepsecurity.io/securerepo?repo=<%= score.org %>/<%= score.repo %>) |
| [<%= score.org %>/<%= score.repo %>](https://<%= score.platform %>/<%= score.org %>/<%= score.repo %>) | [<%= score.commit.slice(0, 7) %>](https://<%= score.platform %>/<%= score.org %>/<%= score.repo %>/commit/<%= score.commit %>) | <% if (!renderBadge) { -%><%= score.score %> <%_ } -%><% if (renderBadge) { -%> [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/<%= score.org %>/<%= score.repo %>/badge)](https://api.securityscorecards.dev/projects/github.com/<%= score.org %>/<%= score.repo %>) <%_ } -%> | <%= score.date %> | <%= score.currentDiff || 0 %> | [Full Report](https://deps.dev/project/github/<%= score.org.toLowerCase() %>%2F<%= score.repo.toLowerCase() %>) | [Fix it](http://app.stepsecurity.io/securerepo?repo=<%= score.org %>/<%= score.repo %>) |
<%_ }); -%>

_Report generated by [UlisesGascon/openssf-scorecard-monitor](https://github.com/UlisesGascon/openssf-scorecard-monitor)._
3 changes: 2 additions & 1 deletion src/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ async function run () {
const reportTagsEnabled = normalizeBoolean(core.getInput('report-tags-enabled'))
const startTag = core.getInput('report-start-tag') || '<!-- OPENSSF-SCORECARD-MONITOR:START -->'
const endTag = core.getInput('report-end-tag') || '<!-- OPENSSF-SCORECARD-MONITOR:END -->'
const renderBadge = normalizeBoolean(core.getInput('render-badge'))

// Error Handling
if (!githubToken && [autoPush, autoCommit, generateIssue, discoveryEnabled].some(value => value)) {
Expand Down Expand Up @@ -91,7 +92,7 @@ async function run () {

// PROCESS
core.info('Generating scores...')
const { reportContent, issueContent, database: newDatabaseState } = await generateScores({ scope, database, maxRequestInParallel, reportTagsEnabled })
const { reportContent, issueContent, database: newDatabaseState } = await generateScores({ scope, database, maxRequestInParallel, reportTagsEnabled, renderBadge })

core.info('Checking database changes...')
const hasChanges = isDifferent(database, newDatabaseState)
Expand Down
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const generateScope = async ({ octokit, orgs, scope, maxRequestInParallel }) =>
return newScope
}

const generateScores = async ({ scope, database: currentDatabase, maxRequestInParallel, reportTagsEnabled }) => {
const generateScores = async ({ scope, database: currentDatabase, maxRequestInParallel, reportTagsEnabled, renderBadge }) => {
// @TODO: Improve deep clone logic
const database = JSON.parse(JSON.stringify(currentDatabase))
const platform = 'github.com'
Expand Down Expand Up @@ -157,8 +157,8 @@ const generateScores = async ({ scope, database: currentDatabase, maxRequestInPa

core.debug('All the scores are already collected')

const reportContent = await generateReportContent(scores, reportTagsEnabled)
const issueContent = await generateIssueContent(scores)
const reportContent = await generateReportContent(scores, reportTagsEnabled, renderBadge)
const issueContent = await generateIssueContent(scores, renderBadge)

// SET OUTPUTS
core.setOutput('scores', scores)
Expand Down
8 changes: 4 additions & 4 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,20 @@ const saveScore = ({ database, platform, org, repo, score, date, commit }) => {
repoRef.current = { score, date, commit }
}

const generateReportContent = async (scores, reportTagsEnabled) => {
const generateReportContent = async (scores, reportTagsEnabled, renderBadge) => {
core.debug('Generating report content')
const template = await readFile(join(process.cwd(), 'templates/report.ejs'), 'utf8')
return ejs.render(template, { scores, reportTagsEnabled })
return ejs.render(template, { scores, reportTagsEnabled, renderBadge })
}

const generateIssueContent = async (scores) => {
const generateIssueContent = async (scores, renderBadge) => {
core.debug('Generating issue content')
const scoresInScope = scores.filter(({ currentDiff }) => currentDiff)
if (!scoresInScope.length) {
return null
}
const template = await readFile(join(process.cwd(), 'templates/issue.ejs'), 'utf8')
return ejs.render(template, { scores: scoresInScope })
return ejs.render(template, { scores: scoresInScope, renderBadge })
}

module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion templates/issue.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ There are changes in the following repositories:
| -- | -- | -- | -- | -- | -- |
<%_ } -%>
<%_ scores.forEach( score => { -%>
| [<%= score.org %>/<%= score.repo %>](https://<%= score.platform %>/<%= score.org %>/<%= score.repo %>) | [<%= score.commit.slice(0, 7) %>](https://<%= score.platform %>/<%= score.org %>/<%= score.repo %>/commit/<%= score.commit %>) | <%= score.score %> | <%= score.currentDiff || 0 %> | [Full Report](https://deps.dev/project/github/<%= score.org.toLowerCase() %>%2F<%= score.repo.toLowerCase() %>) | [Fix it](http://app.stepsecurity.io/securerepo?repo=<%= score.org %>/<%= score.repo %>) |
| [<%= score.org %>/<%= score.repo %>](https://<%= score.platform %>/<%= score.org %>/<%= score.repo %>) | [<%= score.commit.slice(0, 7) %>](https://<%= score.platform %>/<%= score.org %>/<%= score.repo %>/commit/<%= score.commit %>) | <% if (!renderBadge) { -%><%= score.score %> <%_ } -%> <%_ if (renderBadge) { -%> [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/<%= score.org %>/<%= score.repo %>/badge)](https://api.securityscorecards.dev/projects/github.com/<%= score.org %>/<%= score.repo %>) <%_ } -%> | <%= score.currentDiff || 0 %> | [Full Report](https://deps.dev/project/github/<%= score.org.toLowerCase() %>%2F<%= score.repo.toLowerCase() %>) | [Fix it](http://app.stepsecurity.io/securerepo?repo=<%= score.org %>/<%= score.repo %>) |
<%_ }); -%>

_Report generated by [UlisesGascon/openssf-scorecard-monitor](https://github.com/UlisesGascon/openssf-scorecard-monitor)._
2 changes: 1 addition & 1 deletion templates/report.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
| -- | -- | -- | -- | -- | -- | -- |
<%_ } -%>
<%_ scores.forEach( score => { -%>
| [<%= score.org %>/<%= score.repo %>](https://<%= score.platform %>/<%= score.org %>/<%= score.repo %>) | [<%= score.commit.slice(0, 7) %>](https://<%= score.platform %>/<%= score.org %>/<%= score.repo %>/commit/<%= score.commit %>) | <%= score.score %> | <%= score.date %> | <%= score.currentDiff || 0 %> | [Full Report](https://deps.dev/project/github/<%= score.org.toLowerCase() %>%2F<%= score.repo.toLowerCase() %>) | [Fix it](http://app.stepsecurity.io/securerepo?repo=<%= score.org %>/<%= score.repo %>) |
| [<%= score.org %>/<%= score.repo %>](https://<%= score.platform %>/<%= score.org %>/<%= score.repo %>) | [<%= score.commit.slice(0, 7) %>](https://<%= score.platform %>/<%= score.org %>/<%= score.repo %>/commit/<%= score.commit %>) | <% if (!renderBadge) { -%><%= score.score %> <%_ } -%><% if (renderBadge) { -%> [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/<%= score.org %>/<%= score.repo %>/badge)](https://api.securityscorecards.dev/projects/github.com/<%= score.org %>/<%= score.repo %>) <%_ } -%> | <%= score.date %> | <%= score.currentDiff || 0 %> | [Full Report](https://deps.dev/project/github/<%= score.org.toLowerCase() %>%2F<%= score.repo.toLowerCase() %>) | [Fix it](http://app.stepsecurity.io/securerepo?repo=<%= score.org %>/<%= score.repo %>) |
<%_ }); -%>

_Report generated by [UlisesGascon/openssf-scorecard-monitor](https://github.com/UlisesGascon/openssf-scorecard-monitor)._