MCPcopy Index your code
hub / github.com/PyGithub/PyGithub / __create_repository_advisory

Method __create_repository_advisory

github/Repository.py:1934–1989  ·  view source on GitHub ↗
(
        self,
        summary: str,
        description: str,
        severity_or_cvss_vector_string: str,
        cve_id: str | None,
        vulnerabilities: Iterable[github.AdvisoryVulnerability.AdvisoryVulnerabilityInput] | None,
        cwe_ids: Iterable[str] | None,
        credits: Iterable[github.AdvisoryCredit.AdvisoryCredit] | None,
        private_vulnerability_reporting: bool,
    )

Source from the content-addressed store, hash-verified

1932 )
1933
1934 def __create_repository_advisory(
1935 self,
1936 summary: str,
1937 description: str,
1938 severity_or_cvss_vector_string: str,
1939 cve_id: str | None,
1940 vulnerabilities: Iterable[github.AdvisoryVulnerability.AdvisoryVulnerabilityInput] | None,
1941 cwe_ids: Iterable[str] | None,
1942 credits: Iterable[github.AdvisoryCredit.AdvisoryCredit] | None,
1943 private_vulnerability_reporting: bool,
1944 ) -> github.RepositoryAdvisory.RepositoryAdvisory:
1945 if vulnerabilities is None:
1946 vulnerabilities = []
1947 if cwe_ids is None:
1948 cwe_ids = []
1949 assert isinstance(summary, str), summary
1950 assert isinstance(description, str), description
1951 assert isinstance(severity_or_cvss_vector_string, str), severity_or_cvss_vector_string
1952 assert isinstance(cve_id, (str, type(None))), cve_id
1953 assert isinstance(vulnerabilities, Iterable), vulnerabilities
1954 for vulnerability in vulnerabilities:
1955 github.AdvisoryVulnerability.AdvisoryVulnerability._validate_vulnerability(vulnerability)
1956 assert isinstance(cwe_ids, Iterable), cwe_ids
1957 assert all(isinstance(element, str) for element in cwe_ids), cwe_ids
1958 assert isinstance(credits, (Iterable, type(None))), credits
1959 if credits is not None:
1960 for credit in credits:
1961 github.AdvisoryCredit.AdvisoryCredit._validate_credit(credit)
1962 post_parameters = {
1963 "summary": summary,
1964 "description": description,
1965 "vulnerabilities": [
1966 github.AdvisoryVulnerability.AdvisoryVulnerability._to_github_dict(vulnerability)
1967 for vulnerability in vulnerabilities
1968 ],
1969 "cwe_ids": list(cwe_ids),
1970 }
1971 if cve_id is not None:
1972 post_parameters["cve_id"] = cve_id
1973 if credits is not None:
1974 post_parameters["credits"] = [
1975 github.AdvisoryCredit.AdvisoryCredit._to_github_dict(credit) for credit in credits
1976 ]
1977 if severity_or_cvss_vector_string.startswith("CVSS:"):
1978 post_parameters["cvss_vector_string"] = severity_or_cvss_vector_string
1979 else:
1980 post_parameters["severity"] = severity_or_cvss_vector_string
1981 if private_vulnerability_reporting:
1982 headers, data = self._requester.requestJsonAndCheck(
1983 "POST", f"{self.url}/security-advisories/reports", input=post_parameters
1984 )
1985 else:
1986 headers, data = self._requester.requestJsonAndCheck(
1987 "POST", f"{self.url}/security-advisories", input=post_parameters
1988 )
1989 return github.RepositoryAdvisory.RepositoryAdvisory(self._requester, headers, data)
1990
1991 def create_repository_dispatch(self, event_type: str, client_payload: Opt[dict[str, Any]] = NotSet) -> bool:

Callers 2

Calls 4

_validate_creditMethod · 0.80
requestJsonAndCheckMethod · 0.80
_to_github_dictMethod · 0.45

Tested by

no test coverage detected