-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c4844dd
commit c29e971
Showing
8 changed files
with
147 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
APP_PORT=3000 | ||
DATABASE_HOST=localhost | ||
DATABASE_PORT=3306 | ||
DATABASE_USER=root | ||
DATABASE_PASSWORD=root | ||
DATABASE_NAME=nvip | ||
SSVC_API_URL=http://54.147.187.238:5000/ssvc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { | ||
Controller, | ||
Get, | ||
Post, | ||
Body, | ||
Patch, | ||
Param, | ||
Delete, | ||
} from '@nestjs/common'; | ||
import { ExploitsService } from './exploits.service'; | ||
|
||
|
||
@Controller('exploits') | ||
export class ExploitsController { | ||
constructor(private readonly exploitsService: ExploitsService) {} | ||
|
||
@Post() | ||
create(@Body() createExploitDto: any) { | ||
console.log(`${createExploitDto.page}:${createExploitDto.source_url}`) | ||
return this.exploitsService.create(createExploitDto); | ||
} | ||
|
||
@Get() | ||
findAll() { | ||
return this.exploitsService.findAll(); | ||
} | ||
|
||
@Get(':id') | ||
findOne(@Param('id') id: string) { | ||
return this.exploitsService.findOne(+id); | ||
} | ||
|
||
@Patch(':id') | ||
update( | ||
@Param('id') id: string, | ||
@Body() updateExploitDto: any, | ||
) { | ||
return this.exploitsService.update(+id, updateExploitDto); | ||
} | ||
|
||
@Delete(':id') | ||
remove(@Param('id') id: string) { | ||
return this.exploitsService.remove(+id); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { ExploitsService } from './exploits.service'; | ||
import { ExploitsController } from './exploits.controller'; | ||
import { TypeOrmModule } from '@nestjs/typeorm'; | ||
import { Exploit, Vulnerability } from 'src/entities'; | ||
|
||
@Module({ | ||
imports:[ | ||
TypeOrmModule.forFeature([ | ||
Vulnerability, | ||
Exploit, | ||
]), | ||
], | ||
controllers: [ExploitsController], | ||
providers: [ExploitsService], | ||
}) | ||
export class ExploitsModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { InjectRepository } from '@nestjs/typeorm'; | ||
import { Exploit, Vulnerability } from 'src/entities'; | ||
import { Repository } from 'typeorm'; | ||
|
||
@Injectable() | ||
export class ExploitsService { | ||
constructor( | ||
@InjectRepository(Vulnerability) | ||
private vulnRepository: Repository<Vulnerability>, | ||
@InjectRepository(Exploit) | ||
private exploitRepository: Repository<Exploit>, | ||
) {} | ||
|
||
async findVulnerability(cveId:string){ | ||
const vulnerability=await this.vulnRepository.findOne({ | ||
where:{ | ||
cveId:cveId | ||
} | ||
}) | ||
return vulnerability; | ||
} | ||
|
||
async create(createExploitDto: any) { | ||
|
||
var cves = createExploitDto.cve_id.split(','); | ||
for (var cve of cves){ | ||
const currentCve=cve.trim() | ||
console.log(currentCve); | ||
const exploit =this.exploitRepository.create({ | ||
cveId:currentCve, | ||
name:createExploitDto.name, | ||
source:createExploitDto.source, | ||
sourceUrl:createExploitDto.source_url, | ||
description:createExploitDto.description, | ||
fileContent:createExploitDto.file_content?createExploitDto.file_content:null, | ||
isRepo:createExploitDto.is_repo, | ||
datePublished:createExploitDto.date_published, | ||
exampleFile:createExploitDto.file_name, | ||
author:createExploitDto.author, | ||
downloadFailed:false, | ||
ignore:false, | ||
fixed:false, | ||
dateCreated:null | ||
}); | ||
await this.exploitRepository.save(exploit) | ||
|
||
} | ||
return 'This action adds a new exploit'; | ||
|
||
} | ||
|
||
findAll() { | ||
return `This action returns all exploits`; | ||
} | ||
|
||
findOne(id: number) { | ||
return `This action returns a #${id} exploit`; | ||
} | ||
|
||
update(id: number, updateExploitDto: any) { | ||
return `This action updates a #${id} exploit`; | ||
} | ||
|
||
remove(id: number) { | ||
return `This action removes a #${id} exploit`; | ||
} | ||
} |