Skip to content

Commit

Permalink
add platform support
Browse files Browse the repository at this point in the history
  • Loading branch information
Feyd-Rauth committed Mar 5, 2023
1 parent 0e2a6ab commit 9923ece
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/apiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ import axios from 'axios'

namespace ApiService {
export async function getSecuritySentences(requirement: string) {
const response = await axios.post('http://51.178.12.108:8502/text', requirement, {
console.log('Making call to ARQAN')
const response = await axios.post('http://stigsearch.softeam-rd.eu:8000/text', requirement, {
headers: { 'Content-type': 'text/plain;' }
})
console.log('Response data: ', response.data)
return response.data
}

export async function getRecommendedStigs(requirement: string, platform: string): Promise<{ [id: string]: string }> {
const response = await axios.get('http://51.178.12.108:8502/stigs', {
const response = await axios.get('http://stigsearch.softeam-rd.eu:8000/stigs', {
params: { text: requirement, t_type: 1, platform: platform }
})
return response.data
Expand Down
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,22 @@ async function run(): Promise<void> {
const issue = getIssue()
console.log('Issue content: ', issue.content)

// Api is down
const isSecurity = await Requirement.isSecurity(issue.content)
if (isSecurity) await Requirement.setIssueLabel(repo, issue.number, label, token)

// Run suggestion of STIGs and test cases if:
// 1. User specified input STIGs as true
// 2. ARQAN Classification Service encounters issue as security requirement
if (stigs === 'true' && isSecurity) {
// Api is down
const recommendedStigs = await Requirement.getStigs(issue.content, platform)
if (recommendedStigs) {
await Requirement.commentRecommendedStigs(recommendedStigs, repo, issue.number, token)

// INTERACTION with RQCODE repository goes here
await Rqcode.cloneRepo()
const tests = await Rqcode.findTests(recommendedStigs)
const tests = await Rqcode.findTests(recommendedStigs, platform)
await Rqcode.commentFoundTests(tests.found, repo, issue.number, token)
const openedIssues = await Rqcode.openIssues(tests.missing, rqcodeToken)
await Rqcode.commentMissingTests(openedIssues, repo, issue.number, token)
Expand Down
1 change: 1 addition & 0 deletions src/requirement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Stig } from './interfaces'

namespace Requirement {
export async function isSecurity(issue: string): Promise<boolean> {
console.log('In isSecurity function')
// API call to ARQAN to classify the requirement
let securitySentences = await ApiService.getSecuritySentences(issue).then(
(result) => {
Expand Down
7 changes: 5 additions & 2 deletions src/rqcode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ namespace Rqcode {
await executeCommand(`git clone ${rqcodeRepo.url}`, exec)
}

export async function findTests(stigs: Stig[]): Promise<{ found: Test[]; missing: Stig[] }> {
export async function findTests(stigs: Stig[], platform: string): Promise<{ found: Test[]; missing: Stig[] }> {
let found: Test[] = []
let missing: Stig[] = []
const { exec } = require('child_process')
for (let stig of stigs) {
const stigDir = stig.id.replace(/-/g, '_')
await executeCommand(`find ${rqcodeRepo.repo}/src/main/java/rqcode/stigs -type d -name "${stigDir}"`, exec)
await executeCommand(`find ${rqcodeRepo.repo}/src/main/java/rqcode/stigs/${platform} -type d -name "${stigDir}"`, exec)
.then((data) => {
if (data) {
found.push({
Expand All @@ -35,6 +35,7 @@ namespace Rqcode {
missing.push(stig)
})
}
console.log('Missing', missing)
return { found, missing }
}

Expand Down Expand Up @@ -77,8 +78,10 @@ namespace Rqcode {
title: `Implement finding ${stig.id}`,
body: `${stig.url}`
})
console.log('Created issue')
issuesUrls.push({ id: stig.id, url: stig.url, issueUrl: html_url })
}

return issuesUrls
}

Expand Down

0 comments on commit 9923ece

Please sign in to comment.