@@ -1328,3 +1328,389 @@ func TestRepoAdvisoryCreditDetailed_Marshal(t *testing.T) {
13281328
13291329testJSONMarshal (t , u , w )
13301330}
1331+
1332+ func TestCredit_Marshal (t * testing.T ) {
1333+ testJSONMarshal (t , & Credit {}, `{}` )
1334+
1335+ testDate := & Timestamp {time .Date (2019 , time .August , 10 , 14 , 59 , 22 , 0 , time .UTC )}
1336+ u := & Credit {
1337+ Type : String ("t" ),
1338+ User : & User {
1339+ Name : String ("u" ),
1340+ Company : String ("c" ),
1341+ Blog : String ("b" ),
1342+ Location : String ("l" ),
1343+ Email : String ("e" ),
1344+ Hireable : Bool (false ),
1345+ Bio : String ("bio" ),
1346+ TwitterUsername : String ("tu" ),
1347+ PublicRepos : Int (1 ),
1348+ PublicGists : Int (1 ),
1349+ Followers : Int (2 ),
1350+ Following : Int (2 ),
1351+ CreatedAt : testDate ,
1352+ UpdatedAt : testDate ,
1353+ SuspendedAt : testDate ,
1354+ Type : String ("type" ),
1355+ SiteAdmin : Bool (false ),
1356+ TotalPrivateRepos : Int64 (10 ),
1357+ OwnedPrivateRepos : Int64 (10 ),
1358+ PrivateGists : Int (10 ),
1359+ DiskUsage : Int (10 ),
1360+ Collaborators : Int (10 ),
1361+ TwoFactorAuthentication : Bool (true ),
1362+ Plan : & Plan {
1363+ Name : String ("p" ),
1364+ Space : Int (2 ),
1365+ Collaborators : Int (2 ),
1366+ PrivateRepos : Int64 (2 ),
1367+ Seats : Int (2 ),
1368+ FilledSeats : Int (1 ),
1369+ },
1370+ LdapDn : String ("l" ),
1371+ URL : String ("url" ),
1372+ EventsURL : String ("e" ),
1373+ FollowingURL : String ("f" ),
1374+ FollowersURL : String ("f" ),
1375+ GistsURL : String ("g" ),
1376+ OrganizationsURL : String ("o" ),
1377+ ReceivedEventsURL : String ("r" ),
1378+ ReposURL : String ("rep" ),
1379+ StarredURL : String ("star" ),
1380+ SubscriptionsURL : String ("sub" ),
1381+ TextMatches : []* TextMatch {
1382+ {
1383+ ObjectURL : String ("u" ),
1384+ ObjectType : String ("t" ),
1385+ Property : String ("p" ),
1386+ Fragment : String ("f" ),
1387+ Matches : []* Match {
1388+ {
1389+ Text : String ("t" ),
1390+ Indices : []int {1 , 2 },
1391+ },
1392+ },
1393+ },
1394+ },
1395+ Permissions : map [string ]bool {"p1" : true },
1396+ RoleName : String ("r" ),
1397+ },
1398+ }
1399+
1400+ w := `{
1401+ "type": "t",
1402+ "user": {
1403+ "name": "u",
1404+ "company": "c",
1405+ "blog": "b",
1406+ "location": "l",
1407+ "email": "e",
1408+ "hireable": false,
1409+ "bio": "bio",
1410+ "twitter_username": "tu",
1411+ "public_repos": 1,
1412+ "public_gists": 1,
1413+ "followers": 2,
1414+ "following": 2,
1415+ "created_at": "2019-08-10T14:59:22Z",
1416+ "updated_at": "2019-08-10T14:59:22Z",
1417+ "suspended_at": "2019-08-10T14:59:22Z",
1418+ "type": "type",
1419+ "site_admin": false,
1420+ "total_private_repos": 10,
1421+ "owned_private_repos": 10,
1422+ "private_gists": 10,
1423+ "disk_usage": 10,
1424+ "collaborators": 10,
1425+ "two_factor_authentication": true,
1426+ "plan": {
1427+ "name": "p",
1428+ "space": 2,
1429+ "collaborators": 2,
1430+ "private_repos": 2,
1431+ "seats": 2,
1432+ "filled_seats": 1
1433+ },
1434+ "ldap_dn": "l",
1435+ "url": "url",
1436+ "events_url": "e",
1437+ "following_url": "f",
1438+ "followers_url": "f",
1439+ "gists_url": "g",
1440+ "organizations_url": "o",
1441+ "received_events_url": "r",
1442+ "repos_url": "rep",
1443+ "starred_url": "star",
1444+ "subscriptions_url": "sub",
1445+ "text_matches": [
1446+ {
1447+ "object_url": "u",
1448+ "object_type": "t",
1449+ "property": "p",
1450+ "fragment": "f",
1451+ "matches": [
1452+ {
1453+ "text": "t",
1454+ "indices": [1, 2]
1455+ }
1456+ ]
1457+ }
1458+ ],
1459+ "permissions": {
1460+ "p1": true
1461+ },
1462+ "role_name": "r"
1463+ }
1464+ }`
1465+
1466+ testJSONMarshal (t , u , w )
1467+ }
1468+
1469+ func TestGlobalSecurityAdvisory_Marshal (t * testing.T ) {
1470+ testJSONMarshal (t , & GlobalSecurityAdvisory {}, `{}` )
1471+
1472+ testDate := & Timestamp {time .Date (2019 , time .August , 10 , 14 , 59 , 22 , 0 , time .UTC )}
1473+ u := & GlobalSecurityAdvisory {
1474+ ID : Int64 (1 ),
1475+ RepositoryAdvisoryURL : String ("r" ),
1476+ Type : String ("t" ),
1477+ SourceCodeLocation : String ("s" ),
1478+ References : []string {"r" },
1479+ Vulnerabilities : []* GlobalSecurityVulnerability {
1480+ {
1481+ Package : & VulnerabilityPackage {
1482+ Ecosystem : String ("npm" ),
1483+ Name : String ("a-package" ),
1484+ },
1485+ FirstPatchedVersion : String ("1.0.3" ),
1486+ VulnerableVersionRange : String ("<=1.0.2" ),
1487+ VulnerableFunctions : []string {"a_function" },
1488+ },
1489+ },
1490+ GithubReviewedAt : testDate ,
1491+ NVDPublishedAt : testDate ,
1492+ Credits : []* Credit {
1493+ {
1494+ Type : String ("t" ),
1495+ User : & User {
1496+ Name : String ("u" ),
1497+ Company : String ("c" ),
1498+ Blog : String ("b" ),
1499+ Location : String ("l" ),
1500+ Email : String ("e" ),
1501+ Hireable : Bool (false ),
1502+ Bio : String ("bio" ),
1503+ TwitterUsername : String ("tu" ),
1504+ PublicRepos : Int (1 ),
1505+ PublicGists : Int (1 ),
1506+ Followers : Int (2 ),
1507+ Following : Int (2 ),
1508+ CreatedAt : testDate ,
1509+ UpdatedAt : testDate ,
1510+ SuspendedAt : testDate ,
1511+ Type : String ("type" ),
1512+ SiteAdmin : Bool (false ),
1513+ TotalPrivateRepos : Int64 (10 ),
1514+ OwnedPrivateRepos : Int64 (10 ),
1515+ PrivateGists : Int (10 ),
1516+ DiskUsage : Int (10 ),
1517+ Collaborators : Int (10 ),
1518+ TwoFactorAuthentication : Bool (true ),
1519+ Plan : & Plan {
1520+ Name : String ("p" ),
1521+ Space : Int (2 ),
1522+ Collaborators : Int (2 ),
1523+ PrivateRepos : Int64 (2 ),
1524+ Seats : Int (2 ),
1525+ FilledSeats : Int (1 ),
1526+ },
1527+ LdapDn : String ("l" ),
1528+ URL : String ("url" ),
1529+ EventsURL : String ("e" ),
1530+ FollowingURL : String ("f" ),
1531+ FollowersURL : String ("f" ),
1532+ GistsURL : String ("g" ),
1533+ OrganizationsURL : String ("o" ),
1534+ ReceivedEventsURL : String ("r" ),
1535+ ReposURL : String ("rep" ),
1536+ StarredURL : String ("star" ),
1537+ SubscriptionsURL : String ("sub" ),
1538+ TextMatches : []* TextMatch {
1539+ {
1540+ ObjectURL : String ("u" ),
1541+ ObjectType : String ("t" ),
1542+ Property : String ("p" ),
1543+ Fragment : String ("f" ),
1544+ Matches : []* Match {
1545+ {
1546+ Text : String ("t" ),
1547+ Indices : []int {1 , 2 },
1548+ },
1549+ },
1550+ },
1551+ },
1552+ Permissions : map [string ]bool {"p1" : true },
1553+ RoleName : String ("r" ),
1554+ },
1555+ },
1556+ },
1557+ SecurityAdvisory : SecurityAdvisory {
1558+ GHSAID : String ("GHSA-xoxo-1234-xoxo" ),
1559+ CVEID : String ("CVE-xoxo-1234" ),
1560+ URL : String ("https://api.github.com/advisories/GHSA-xoxo-1234-xoxo" ),
1561+ HTMLURL : String ("https://github.com/advisories/GHSA-xoxo-1234-xoxo" ),
1562+ Severity : String ("high" ),
1563+ Summary : String ("Heartbleed security advisory" ),
1564+ Description : String ("This bug allows an attacker to read portions of the affected server’s memory, potentially disclosing sensitive information." ),
1565+ Identifiers : []* AdvisoryIdentifier {
1566+ {
1567+ Type : String ("GHSA" ),
1568+ Value : String ("GHSA-xoxo-1234-xoxo" ),
1569+ },
1570+ {
1571+ Type : String ("CVE" ),
1572+ Value : String ("CVE-xoxo-1234" ),
1573+ },
1574+ },
1575+ PublishedAt : testDate ,
1576+ UpdatedAt : testDate ,
1577+ WithdrawnAt : nil ,
1578+ CVSS : & AdvisoryCVSS {
1579+ VectorString : String ("CVSS:3.1/AV:N/AC:H/PR:H/UI:R/S:C/C:H/I:H/A:H" ),
1580+ Score : Float64 (7.6 ),
1581+ },
1582+ CWEs : []* AdvisoryCWEs {
1583+ {
1584+ CWEID : String ("CWE-400" ),
1585+ Name : String ("Uncontrolled Resource Consumption" ),
1586+ },
1587+ },
1588+ },
1589+ }
1590+
1591+ w := `{
1592+ "cvss": {
1593+ "score": 7.6,
1594+ "vector_string": "CVSS:3.1/AV:N/AC:H/PR:H/UI:R/S:C/C:H/I:H/A:H"
1595+ },
1596+ "cwes": [
1597+ {
1598+ "cwe_id": "CWE-400",
1599+ "name": "Uncontrolled Resource Consumption"
1600+ }
1601+ ],
1602+ "ghsa_id": "GHSA-xoxo-1234-xoxo",
1603+ "summary": "Heartbleed security advisory",
1604+ "description": "This bug allows an attacker to read portions of the affected server’s memory, potentially disclosing sensitive information.",
1605+ "severity": "high",
1606+ "identifiers": [
1607+ {
1608+ "value": "GHSA-xoxo-1234-xoxo",
1609+ "type": "GHSA"
1610+ },
1611+ {
1612+ "value": "CVE-xoxo-1234",
1613+ "type": "CVE"
1614+ }
1615+ ],
1616+ "published_at": "2019-08-10T14:59:22Z",
1617+ "updated_at": "2019-08-10T14:59:22Z",
1618+ "cve_id": "CVE-xoxo-1234",
1619+ "url": "https://api.github.com/advisories/GHSA-xoxo-1234-xoxo",
1620+ "html_url": "https://github.com/advisories/GHSA-xoxo-1234-xoxo",
1621+ "id": 1,
1622+ "repository_advisory_url": "r",
1623+ "type": "t",
1624+ "source_code_location": "s",
1625+ "references": [
1626+ "r"
1627+ ],
1628+ "vulnerabilities": [
1629+ {
1630+ "package": {
1631+ "ecosystem": "npm",
1632+ "name": "a-package"
1633+ },
1634+ "first_patched_version": "1.0.3",
1635+ "vulnerable_version_range": "\u003c=1.0.2",
1636+ "vulnerable_functions": [
1637+ "a_function"
1638+ ]
1639+ }
1640+ ],
1641+ "github_reviewed_at": "2019-08-10T14:59:22Z",
1642+ "nvd_published_at": "2019-08-10T14:59:22Z",
1643+ "credits": [
1644+ {
1645+ "user": {
1646+ "name": "u",
1647+ "company": "c",
1648+ "blog": "b",
1649+ "location": "l",
1650+ "email": "e",
1651+ "hireable": false,
1652+ "bio": "bio",
1653+ "twitter_username": "tu",
1654+ "public_repos": 1,
1655+ "public_gists": 1,
1656+ "followers": 2,
1657+ "following": 2,
1658+ "created_at": "2019-08-10T14:59:22Z",
1659+ "updated_at": "2019-08-10T14:59:22Z",
1660+ "suspended_at": "2019-08-10T14:59:22Z",
1661+ "type": "type",
1662+ "site_admin": false,
1663+ "total_private_repos": 10,
1664+ "owned_private_repos": 10,
1665+ "private_gists": 10,
1666+ "disk_usage": 10,
1667+ "collaborators": 10,
1668+ "two_factor_authentication": true,
1669+ "plan": {
1670+ "name": "p",
1671+ "space": 2,
1672+ "collaborators": 2,
1673+ "private_repos": 2,
1674+ "filled_seats": 1,
1675+ "seats": 2
1676+ },
1677+ "ldap_dn": "l",
1678+ "url": "url",
1679+ "events_url": "e",
1680+ "following_url": "f",
1681+ "followers_url": "f",
1682+ "gists_url": "g",
1683+ "organizations_url": "o",
1684+ "received_events_url": "r",
1685+ "repos_url": "rep",
1686+ "starred_url": "star",
1687+ "subscriptions_url": "sub",
1688+ "text_matches": [
1689+ {
1690+ "object_url": "u",
1691+ "object_type": "t",
1692+ "property": "p",
1693+ "fragment": "f",
1694+ "matches": [
1695+ {
1696+ "text": "t",
1697+ "indices": [
1698+ 1,
1699+ 2
1700+ ]
1701+ }
1702+ ]
1703+ }
1704+ ],
1705+ "permissions": {
1706+ "p1": true
1707+ },
1708+ "role_name": "r"
1709+ },
1710+ "type": "t"
1711+ }
1712+ ]
1713+ }`
1714+
1715+ testJSONMarshal (t , u , w )
1716+ }
0 commit comments