def generate_commit_data(): return VulnerabilityGitCommits( commit_link='https://github.com/0WN3R/REP0', commit_hash='F00D', repo_name='REP0', repo_owner='0WN3R', )
def get_or_create_vulnerability(self): if self._vulnerability: return self._vulnerability default_cve_id = None if self._nvd_data is not None: default_cve_id = self._nvd_data.cve_id return Vulnerability( cve_id=default_cve_id, commits=[ VulnerabilityGitCommits(commit_link=self.commit_link, repo_name=self.repo_name, repo_url=self.repo_url, commit_hash=self.commit_hash) ], comment='', creator=g.user, )
def nvd_to_vcdb(nvd, commit_link): vcs_handler = get_vcs_handler(app, commit_link) if not vcs_handler: print("Can't parse Vcs link: {}".format(commit_link)) #print(vars(nvd)) return None vulnerability = Vulnerability( cve_id=nvd.cve_id, commits=[ VulnerabilityGitCommits(commit_link=commit_link, commit_hash=vcs_handler.commit_hash, repo_name=vcs_handler.repo_name, repo_owner=vcs_handler.repo_owner, repo_url=vcs_handler.repo_url) ], comment='', ) return vulnerability
class VulnerabilityDetailsForm(FlaskForm): commits = ModelFieldList(FormField(CommitLinksForm), model=VulnerabilityGitCommits, min_entries=1, default=[lambda: VulnerabilityGitCommits()]) # The filters argument is used to have Null fields instead of empty strings. # This is important since the cve_id is supposed to be unique OR Null. cve_id = StringField( 'CVE-ID (if applicable)', filters=[lambda x: x and str(x).upper().strip(), lambda x: x or None], validators=[ validators.Optional(), validators.Regexp(r'^CVE-\d{4}-\d+$') ]) comment = TextAreaField('High-Level Bug Overview', validators=[validators.DataRequired()]) additional_resources = ModelFieldList( FormField(VulnerabilityResourcesForm), model=VulnerabilityResources) submit = SubmitField('Create/Update')
def get_or_create_vulnerability(self) -> Vulnerability: if self._vulnerability: return self._vulnerability logging.debug('Vulnerability not found creating new instance') default_cve_id = None if self._nvd_data is not None: default_cve_id = self._nvd_data.cve_id default_vulnerability = Vulnerability( cve_id=default_cve_id, commits=[ VulnerabilityGitCommits( commit_link=self.commit_link, repo_name=self.repo_name, repo_url=self.repo_url, commit_hash=self.commit_hash, ) ], comment="", creator=g.user, ) return default_vulnerability
def create_vcdb_entry(cve_id, commit_link=None): vuln_commits = [] if commit_link: vcs_handler = get_vcs_handler(app, commit_link) if not vcs_handler: print("Can't parse Vcs link: {}".format(commit_link)) return None vuln_commit = VulnerabilityGitCommits( commit_link=commit_link, commit_hash=vcs_handler.commit_hash, repo_name=vcs_handler.repo_name, repo_owner=vcs_handler.repo_owner, repo_url=vcs_handler.repo_url, ) vuln_commits.append(vuln_commit) vulnerability = Vulnerability( cve_id=cve_id, commits=vuln_commits, comment="", ) return vulnerability
def create_vcdb_entry(cve_id, commit_link=None): vuln_commits = [] if commit_link: vcs_handler = get_vcs_handler(app, commit_link) if not vcs_handler: print(f"Can't parse Vcs link: {commit_link}") return None vuln_commit = VulnerabilityGitCommits( commit_link=commit_link, commit_hash=vcs_handler.commit_hash, repo_name=vcs_handler.repo_name, repo_owner=vcs_handler.repo_owner, repo_url=vcs_handler.repo_url, ) vuln_commits.append(vuln_commit) vulnerability = Vulnerability(cve_id=cve_id, commits=vuln_commits, comment="", version=0, state=VulnerabilityState.PUBLISHED) return vulnerability