Skip to content

Commit

Permalink
Add stigs limit.
Browse files Browse the repository at this point in the history
  • Loading branch information
Feyd-Rauth committed Apr 23, 2023
1 parent b0bb592 commit 8f0b572
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ inputs:
password:
description: 'ARQAN password'
required: true
limit:
description: 'Max number of suggested STIGs'
required: false
default: '5'
runs:
using: 'node16'
main: 'dist/index.js'
5 changes: 3 additions & 2 deletions src/apiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,12 @@ namespace ApiService {
return response.data
}

export async function getRecommendedStigs(requirement: string, platform: string, token: string): Promise<Array<any>> {
export async function getRecommendedStigs(requirement: string, platform: string, limit: number, token: string): Promise<Array<any>> {
let response = await axios.post('http://51.250.88.251:8000/api/tasks/sec-req-search-db',
{
'text': requirement,
'platform': platform
'platform': platform,
'limit': limit
},
{
headers: {
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ async function run(): Promise<void> {
const platform = sanitizeUrl(getInput('platform', {required: false}))
const username = getInput('username', {required: true})
const password = getInput('password', {required: true})
const limit = parseInt(getInput('limit', {required: false}))

// get repo context
const repo = getRepo()
Expand All @@ -33,7 +34,7 @@ async function run(): Promise<void> {
// 1. User specified input STIGs as true
// 2. ARQAN Classification Service encounters issue as security requirement
if (stigs === 'true' && isSecurity) {
const recommendedStigs = await Requirement.getStigs(issue.content, platform, arqan_token)
const recommendedStigs = await Requirement.getStigs(issue.content, platform, limit, arqan_token)
if (recommendedStigs) {
await Requirement.commentRecommendedStigs(recommendedStigs, repo, issue.number, token)

Expand Down
4 changes: 2 additions & 2 deletions src/requirement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ namespace Requirement {
})
}

export async function getStigs(requirement: string, platform: string, token: string): Promise<Stig[]> {
export async function getStigs(requirement: string, platform: string, limit: number, token: string): Promise<Stig[]> {
// array for STIGs to the particular requirement
let stigs: Array<Stig> = []
let response = await ApiService.getRecommendedStigs(requirement, platform, token)
let response = await ApiService.getRecommendedStigs(requirement, platform, limit, token)
if (response.length === 0) {
return stigs
}
Expand Down

0 comments on commit 8f0b572

Please sign in to comment.