@socketsecurity/cli-with-sentry 0.14.53 → 0.14.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -27,6 +27,7 @@ var index = require('./index.js');
27
27
  var constants = require('./constants.js');
28
28
  var objects = require('@socketsecurity/registry/lib/objects');
29
29
  var regexps = require('@socketsecurity/registry/lib/regexps');
30
+ var commonTags = _socketInterop(require('common-tags'));
30
31
  var fs$1 = require('node:fs/promises');
31
32
  var ScreenWidget = _socketInterop(require('blessed/lib/widgets/screen'));
32
33
  var contrib = _socketInterop(require('blessed-contrib'));
@@ -1515,7 +1516,7 @@ function meowOrExit({
1515
1516
  }
1516
1517
  function getAsciiHeader(command) {
1517
1518
  const cliVersion = // The '@rollup/plugin-replace' will replace "process.env['SOCKET_CLI_VERSION_HASH']".
1518
- "0.14.53:e7fcb39:b41fef49:pub";
1519
+ "0.14.55:51de259:b691b88f:pub";
1519
1520
  const nodeVersion = process.version;
1520
1521
  const apiToken = index.getSetting('apiToken');
1521
1522
  const shownToken = apiToken ? getLastFiveOfApiToken(apiToken) : 'no';
@@ -1589,15 +1590,87 @@ async function run$z(argv, importMeta, {
1589
1590
  await runAction(githubEventBefore, githubEventAfter);
1590
1591
  }
1591
1592
 
1593
+ async function fetchOrgAnalyticsData(time, spinner, apiToken) {
1594
+ const socketSdk = await index.setupSdk(apiToken);
1595
+ const result = await handleApiCall(socketSdk.getOrgAnalytics(time.toString()), 'fetching analytics data');
1596
+ if (result.success === false) {
1597
+ handleUnsuccessfulApiResponse('getOrgAnalytics', result, spinner);
1598
+ return undefined;
1599
+ }
1600
+ spinner.stop();
1601
+ if (!result.data.length) {
1602
+ logger.logger.log('No analytics data is available for this organization yet.');
1603
+ return undefined;
1604
+ }
1605
+ return result.data;
1606
+ }
1607
+
1608
+ async function fetchRepoAnalyticsData(repo, time, spinner, apiToken) {
1609
+ const socketSdk = await index.setupSdk(apiToken);
1610
+ const result = await handleApiCall(socketSdk.getRepoAnalytics(repo, time.toString()), 'fetching analytics data');
1611
+ if (result.success === false) {
1612
+ handleUnsuccessfulApiResponse('getRepoAnalytics', result, spinner);
1613
+ return undefined;
1614
+ }
1615
+ spinner.stop();
1616
+ if (!result.data.length) {
1617
+ logger.logger.log('No analytics data is available for this organization yet.');
1618
+ return undefined;
1619
+ }
1620
+ return result.data;
1621
+ }
1622
+
1623
+ function mdTableStringNumber(title1, title2, obj) {
1624
+ // | Date | Counts |
1625
+ // | ----------- | ------ |
1626
+ // | Header | 201464 |
1627
+ // | Paragraph | 18 |
1628
+ let mw1 = title1.length;
1629
+ let mw2 = title2.length;
1630
+ for (const [key, value] of Object.entries(obj)) {
1631
+ mw1 = Math.max(mw1, key.length);
1632
+ mw2 = Math.max(mw2, String(value ?? '').length);
1633
+ }
1634
+ const lines = [];
1635
+ lines.push(`| ${title1.padEnd(mw1, ' ')} | ${title2.padEnd(mw2)} |`);
1636
+ lines.push(`| ${'-'.repeat(mw1)} | ${'-'.repeat(mw2)} |`);
1637
+ for (const [key, value] of Object.entries(obj)) {
1638
+ lines.push(`| ${key.padEnd(mw1, ' ')} | ${String(value ?? '').padStart(mw2, ' ')} |`);
1639
+ }
1640
+ lines.push(`| ${'-'.repeat(mw1)} | ${'-'.repeat(mw2)} |`);
1641
+ return lines.join('\n');
1642
+ }
1643
+
1592
1644
  // Note: Widgets does not seem to actually work as code :'(
1593
1645
 
1646
+ const METRICS = ['total_critical_alerts', 'total_high_alerts', 'total_medium_alerts', 'total_low_alerts', 'total_critical_added', 'total_medium_added', 'total_low_added', 'total_high_added', 'total_critical_prevented', 'total_high_prevented', 'total_medium_prevented', 'total_low_prevented'];
1647
+
1594
1648
  // Note: This maps `new Date(date).getMonth()` to English three letters
1595
1649
  const Months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
1596
- const METRICS = ['total_critical_alerts', 'total_high_alerts', 'total_medium_alerts', 'total_low_alerts', 'total_critical_added', 'total_medium_added', 'total_low_added', 'total_high_added', 'total_critical_prevented', 'total_high_prevented', 'total_medium_prevented', 'total_low_prevented'];
1597
1650
  async function displayAnalytics({
1651
+ filePath,
1652
+ outputKind,
1653
+ repo,
1654
+ scope,
1655
+ time
1656
+ }) {
1657
+ const apiToken = index.getDefaultToken();
1658
+ if (!apiToken) {
1659
+ throw new index.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API token.');
1660
+ }
1661
+ await outputAnalyticsWithToken({
1662
+ apiToken,
1663
+ filePath,
1664
+ outputKind,
1665
+ repo,
1666
+ scope,
1667
+ time
1668
+ });
1669
+ }
1670
+ async function outputAnalyticsWithToken({
1598
1671
  apiToken,
1599
1672
  filePath,
1600
- outputJson,
1673
+ outputKind,
1601
1674
  repo,
1602
1675
  scope,
1603
1676
  time
@@ -1613,22 +1686,70 @@ async function displayAnalytics({
1613
1686
  } else if (repo) {
1614
1687
  data = await fetchRepoAnalyticsData(repo, time, spinner, apiToken);
1615
1688
  }
1616
- if (data) {
1617
- if (outputJson && !filePath) {
1618
- logger.logger.log(data);
1619
- } else if (filePath) {
1689
+
1690
+ // A message should already have been printed if we have no data here
1691
+ if (!data) return;
1692
+ if (outputKind === 'json') {
1693
+ let serialized = renderJson(data);
1694
+ if (!serialized) return;
1695
+ if (filePath && filePath !== '-') {
1620
1696
  try {
1621
- await fs$1.writeFile(filePath, JSON.stringify(data), 'utf8');
1697
+ await fs$1.writeFile(filePath, serialized, 'utf8');
1622
1698
  logger.logger.log(`Data successfully written to ${filePath}`);
1623
1699
  } catch (e) {
1700
+ logger.logger.error('There was an error trying to write the json to disk');
1624
1701
  logger.logger.error(e);
1702
+ process.exitCode = 1;
1703
+ }
1704
+ } else {
1705
+ logger.logger.log(serialized);
1706
+ }
1707
+ } else {
1708
+ const fdata = scope === 'org' ? formatDataOrg(data) : formatDataRepo(data);
1709
+ if (outputKind === 'markdown') {
1710
+ const serialized = renderMarkdown(fdata, time, repo);
1711
+ if (filePath && filePath !== '-') {
1712
+ try {
1713
+ await fs$1.writeFile(filePath, serialized, 'utf8');
1714
+ logger.logger.log(`Data successfully written to ${filePath}`);
1715
+ } catch (e) {
1716
+ logger.logger.error(e);
1717
+ }
1718
+ } else {
1719
+ logger.logger.log(serialized);
1625
1720
  }
1626
1721
  } else {
1627
- const fdata = scope === 'org' ? formatData(data, 'org') : formatData(data, 'repo');
1628
1722
  displayAnalyticsScreen(fdata);
1629
1723
  }
1630
1724
  }
1631
1725
  }
1726
+ function renderJson(data) {
1727
+ try {
1728
+ return JSON.stringify(data, null, 2);
1729
+ } catch (e) {
1730
+ // This could be caused by circular references, which is an "us" problem
1731
+ logger.logger.error('There was a problem converting the data set to JSON. Please try without --json or with --markdown');
1732
+ process.exitCode = 1;
1733
+ return;
1734
+ }
1735
+ }
1736
+ function renderMarkdown(data, days, repoSlug) {
1737
+ return commonTags.stripIndents`
1738
+ # Socket Alert Analytics
1739
+
1740
+ These are the Socket.dev stats are analytics for the ${repoSlug ? `${repoSlug} repo` : 'org'} of the past ${days} days
1741
+
1742
+ ${[['Total critical alerts', mdTableStringNumber('Date', 'Counts', data['total_critical_alerts'])], ['Total high alerts', mdTableStringNumber('Date', 'Counts', data['total_high_alerts'])], ['Total critical alerts added to the main branch', mdTableStringNumber('Date', 'Counts', data['total_critical_added'])], ['Total high alerts added to the main branch', mdTableStringNumber('Date', 'Counts', data['total_high_added'])], ['Total critical alerts prevented from the main branch', mdTableStringNumber('Date', 'Counts', data['total_critical_prevented'])], ['Total high alerts prevented from the main branch', mdTableStringNumber('Date', 'Counts', data['total_high_prevented'])], ['Total medium alerts prevented from the main branch', mdTableStringNumber('Date', 'Counts', data['total_medium_prevented'])], ['Total low alerts prevented from the main branch', mdTableStringNumber('Date', 'Counts', data['total_low_prevented'])]].map(([title, table]) => commonTags.stripIndents`
1743
+ ## ${title}
1744
+
1745
+ ${table}
1746
+ `).join('\n\n')}
1747
+
1748
+ ## Top 5 alert types
1749
+
1750
+ ${mdTableStringNumber('Name', 'Counts', data['top_five_alert_types'])}
1751
+ `;
1752
+ }
1632
1753
  function displayAnalyticsScreen(data) {
1633
1754
  const screen = new ScreenWidget({});
1634
1755
  const grid = new contrib.grid({
@@ -1661,91 +1782,69 @@ function displayAnalyticsScreen(data) {
1661
1782
  screen.render();
1662
1783
  screen.key(['escape', 'q', 'C-c'], () => process.exit(0));
1663
1784
  }
1664
- async function fetchOrgAnalyticsData(time, spinner, apiToken) {
1665
- const socketSdk = await index.setupSdk(apiToken);
1666
- const result = await handleApiCall(socketSdk.getOrgAnalytics(time.toString()), 'fetching analytics data');
1667
- if (result.success === false) {
1668
- handleUnsuccessfulApiResponse('getOrgAnalytics', result, spinner);
1669
- return undefined;
1785
+ function formatDataRepo(data) {
1786
+ const sortedTopFiveAlerts = {};
1787
+ const totalTopAlerts = {};
1788
+ const formattedData = {};
1789
+ for (const metric of METRICS) {
1790
+ formattedData[metric] = {};
1670
1791
  }
1671
- spinner.stop();
1672
- if (!result.data.length) {
1673
- logger.logger.log('No analytics data is available for this organization yet.');
1674
- return undefined;
1792
+ for (const entry of data) {
1793
+ const topFiveAlertTypes = entry['top_five_alert_types'];
1794
+ for (const type of Object.keys(topFiveAlertTypes)) {
1795
+ const count = topFiveAlertTypes[type] ?? 0;
1796
+ if (!totalTopAlerts[type]) {
1797
+ totalTopAlerts[type] = count;
1798
+ } else if (count > (totalTopAlerts[type] ?? 0)) {
1799
+ totalTopAlerts[type] = count;
1800
+ }
1801
+ }
1675
1802
  }
1676
- return result.data;
1677
- }
1678
- async function fetchRepoAnalyticsData(repo, time, spinner, apiToken) {
1679
- const socketSdk = await index.setupSdk(apiToken);
1680
- const result = await handleApiCall(socketSdk.getRepoAnalytics(repo, time.toString()), 'fetching analytics data');
1681
- if (result.success === false) {
1682
- handleUnsuccessfulApiResponse('getRepoAnalytics', result, spinner);
1683
- return undefined;
1803
+ for (const entry of data) {
1804
+ for (const metric of METRICS) {
1805
+ formattedData[metric][formatDate(entry['created_at'])] = entry[metric];
1806
+ }
1684
1807
  }
1685
- spinner.stop();
1686
- if (!result.data.length) {
1687
- logger.logger.log('No analytics data is available for this organization yet.');
1688
- return undefined;
1808
+ const topFiveAlertEntries = Object.entries(totalTopAlerts).sort(([_keya, a], [_keyb, b]) => b - a).slice(0, 5);
1809
+ for (const [key, value] of topFiveAlertEntries) {
1810
+ sortedTopFiveAlerts[key] = value;
1689
1811
  }
1690
- return result.data;
1812
+ return {
1813
+ ...formattedData,
1814
+ top_five_alert_types: sortedTopFiveAlerts
1815
+ };
1691
1816
  }
1692
- function formatData(data, scope) {
1693
- const formattedData = {};
1817
+ function formatDataOrg(data) {
1694
1818
  const sortedTopFiveAlerts = {};
1695
1819
  const totalTopAlerts = {};
1820
+ const formattedData = {};
1696
1821
  for (const metric of METRICS) {
1697
1822
  formattedData[metric] = {};
1698
1823
  }
1699
- if (scope === 'org') {
1700
- for (const entry of data) {
1701
- const topFiveAlertTypes = entry['top_five_alert_types'];
1702
- for (const type of Object.keys(topFiveAlertTypes)) {
1703
- const count = topFiveAlertTypes[type] ?? 0;
1704
- if (!totalTopAlerts[type]) {
1705
- totalTopAlerts[type] = count;
1706
- } else {
1707
- totalTopAlerts[type] += count;
1708
- }
1709
- }
1710
- }
1711
- for (const metric of METRICS) {
1712
- const formatted = formattedData[metric];
1713
- for (const entry of data) {
1714
- const date = formatDate(entry['created_at']);
1715
- if (!formatted[date]) {
1716
- formatted[date] = entry[metric];
1717
- } else {
1718
- formatted[date] += entry[metric];
1719
- }
1720
- }
1721
- }
1722
- } else if (scope === 'repo') {
1723
- for (const entry of data) {
1724
- const topFiveAlertTypes = entry['top_five_alert_types'];
1725
- for (const type of Object.keys(topFiveAlertTypes)) {
1726
- const count = topFiveAlertTypes[type] ?? 0;
1727
- if (!totalTopAlerts[type]) {
1728
- totalTopAlerts[type] = count;
1729
- } else if (count > (totalTopAlerts[type] ?? 0)) {
1730
- totalTopAlerts[type] = count;
1731
- }
1824
+ for (const entry of data) {
1825
+ const topFiveAlertTypes = entry['top_five_alert_types'];
1826
+ for (const type of Object.keys(topFiveAlertTypes)) {
1827
+ const count = topFiveAlertTypes[type] ?? 0;
1828
+ if (!totalTopAlerts[type]) {
1829
+ totalTopAlerts[type] = count;
1830
+ } else {
1831
+ totalTopAlerts[type] += count;
1732
1832
  }
1733
1833
  }
1834
+ }
1835
+ for (const metric of METRICS) {
1836
+ const formatted = formattedData[metric];
1734
1837
  for (const entry of data) {
1735
- for (const metric of METRICS) {
1736
- formattedData[metric][formatDate(entry['created_at'])] = entry[metric];
1838
+ const date = formatDate(entry['created_at']);
1839
+ if (!formatted[date]) {
1840
+ formatted[date] = entry[metric];
1841
+ } else {
1842
+ formatted[date] += entry[metric];
1737
1843
  }
1738
1844
  }
1739
1845
  }
1740
- const topFiveAlertEntries = Object.entries(totalTopAlerts).sort(({
1741
- 1: a
1742
- }, {
1743
- 1: b
1744
- }) => b - a).slice(0, 5);
1745
- for (const {
1746
- 0: key,
1747
- 1: value
1748
- } of topFiveAlertEntries) {
1846
+ const topFiveAlertEntries = Object.entries(totalTopAlerts).sort(([_keya, a], [_keyb, b]) => b - a).slice(0, 5);
1847
+ for (const [key, value] of topFiveAlertEntries) {
1749
1848
  sortedTopFiveAlerts[key] = value;
1750
1849
  }
1751
1850
  return {
@@ -1790,6 +1889,18 @@ const config$y = {
1790
1889
  flags: {
1791
1890
  ...commonFlags,
1792
1891
  ...outputFlags,
1892
+ file: {
1893
+ type: 'string',
1894
+ shortFlag: 'f',
1895
+ default: '-',
1896
+ description: 'Path to a local file to save the output. Only valid with --json/--markdown. Defaults to stdout.'
1897
+ },
1898
+ repo: {
1899
+ type: 'string',
1900
+ shortFlag: 'r',
1901
+ default: '',
1902
+ description: 'Name of the repository. Only valid when scope=repo'
1903
+ },
1793
1904
  scope: {
1794
1905
  type: 'string',
1795
1906
  shortFlag: 's',
@@ -1801,18 +1912,6 @@ const config$y = {
1801
1912
  shortFlag: 't',
1802
1913
  default: 7,
1803
1914
  description: 'Time filter - either 7, 30 or 90, default: 7'
1804
- },
1805
- repo: {
1806
- type: 'string',
1807
- shortFlag: 'r',
1808
- default: '',
1809
- description: 'Name of the repository'
1810
- },
1811
- file: {
1812
- type: 'string',
1813
- shortFlag: 'f',
1814
- default: '',
1815
- description: 'Path to a local file to save the output'
1816
1915
  }
1817
1916
  },
1818
1917
  help: (command, {
@@ -1848,6 +1947,9 @@ async function run$y(argv, importMeta, {
1848
1947
  parentName
1849
1948
  });
1850
1949
  const {
1950
+ file,
1951
+ json,
1952
+ markdown,
1851
1953
  repo,
1852
1954
  scope,
1853
1955
  time
@@ -1855,66 +1957,154 @@ async function run$y(argv, importMeta, {
1855
1957
  const badScope = scope !== 'org' && scope !== 'repo';
1856
1958
  const badTime = time !== 7 && time !== 30 && time !== 90;
1857
1959
  const badRepo = scope === 'repo' && !repo;
1858
- if (badScope || badTime || badRepo) {
1960
+ const badFile = file !== '-' && !json && !markdown;
1961
+ const badFlags = json && markdown;
1962
+ if (badScope || badTime || badRepo || badFile || badFlags) {
1859
1963
  // Use exit status of 2 to indicate incorrect usage, generally invalid
1860
1964
  // options or missing arguments.
1861
1965
  // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
1862
1966
  process.exitCode = 2;
1863
- logger.logger.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
1864
- - Scope must be "repo" or "org" ${badScope ? colors.red('(bad!)') : colors.green('(ok)')}\n
1865
- - The time filter must either be 7, 30 or 90 ${badTime ? colors.red('(bad!)') : colors.green('(ok)')}\n
1866
- - Repository name using --repo when scope is "repo" ${badRepo ? colors.red('(bad!)') : colors.green('(ok)')}\n`);
1967
+ logger.logger.error(commonTags.stripIndents`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:
1968
+
1969
+ - Scope must be "repo" or "org" ${badScope ? colors.red('(bad!)') : colors.green('(ok)')}
1970
+
1971
+ - The time filter must either be 7, 30 or 90 ${badTime ? colors.red('(bad!)') : colors.green('(ok)')}
1972
+
1973
+ ${scope === 'repo' ? `- Repository name using --repo when scope is "repo" ${badRepo ? colors.red('(bad!)') : colors.green('(ok)')}` : ''}
1974
+
1975
+ ${badFlags ? `- The \`--json\` and \`--markdown\` flags can not be used at the same time ${badFlags ? colors.red('(bad!)') : colors.green('(ok)')}` : ''}
1976
+
1977
+ ${badFile ? `- The \`--file\` flag is only valid when using \`--json\` or \`--markdown\` ${badFile ? colors.red('(bad!)') : colors.green('(ok)')}` : ''}
1978
+ `.split('\n').filter(s => !!s.trim()).join('\n'));
1867
1979
  return;
1868
1980
  }
1869
1981
  if (cli.flags['dryRun']) {
1870
1982
  logger.logger.log(DRY_RUN_BAIL_TEXT$x);
1871
1983
  return;
1872
1984
  }
1873
- const apiToken = index.getDefaultToken();
1874
- if (!apiToken) {
1875
- throw new index.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API token.');
1876
- }
1877
1985
  return await displayAnalytics({
1878
- apiToken,
1879
1986
  scope,
1880
1987
  time,
1881
1988
  repo: String(repo || ''),
1882
- outputJson: Boolean(cli.flags['json']),
1883
- filePath: String(cli.flags['file'] || '')
1989
+ outputKind: json ? 'json' : markdown ? 'markdown' : 'print',
1990
+ filePath: String(file || '')
1884
1991
  });
1885
1992
  }
1886
1993
 
1887
1994
  async function getAuditLog({
1888
- apiToken,
1995
+ logType,
1889
1996
  orgSlug,
1890
- outputJson,
1891
- outputMarkdown,
1997
+ outputKind,
1892
1998
  page,
1893
- perPage,
1894
- type
1999
+ perPage
1895
2000
  }) {
1896
- // Lazily access constants.spinner.
1897
- const {
1898
- spinner
1899
- } = constants;
1900
- spinner.start(`Looking up audit log for ${orgSlug}`);
1901
- const socketSdk = await index.setupSdk(apiToken);
1902
- const result = await handleApiCall(socketSdk.getAuditLogEvents(orgSlug, {
1903
- outputJson,
1904
- outputMarkdown,
2001
+ const apiToken = index.getDefaultToken();
2002
+ if (!apiToken) {
2003
+ throw new index.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
2004
+ }
2005
+ const auditLogs = await getAuditLogWithToken({
2006
+ apiToken,
1905
2007
  orgSlug,
1906
- type,
2008
+ outputKind,
1907
2009
  page,
1908
- per_page: perPage
1909
- }), `Looking up audit log for ${orgSlug}\n`);
1910
- if (!result.success) {
1911
- handleUnsuccessfulApiResponse('getAuditLogEvents', result, spinner);
2010
+ perPage,
2011
+ logType
2012
+ });
2013
+ if (!auditLogs) return;
2014
+ if (outputKind === 'json') await outputAsJson(auditLogs.results, orgSlug, logType, page, perPage);else if (outputKind === 'markdown') await outputAsMarkdown(auditLogs.results, orgSlug, logType, page, perPage);else await outputAsPrint(auditLogs.results, orgSlug, logType);
2015
+ }
2016
+ async function outputAsJson(auditLogs, orgSlug, logType, page, perPage) {
2017
+ let json;
2018
+ try {
2019
+ json = JSON.stringify({
2020
+ desc: 'Audit logs for given query',
2021
+ generated: new Date().toISOString(),
2022
+ org: orgSlug,
2023
+ logType,
2024
+ page,
2025
+ perPage,
2026
+ logs: auditLogs.map(log => {
2027
+ // Note: The subset is pretty arbitrary
2028
+ const {
2029
+ created_at,
2030
+ event_id,
2031
+ ip_address,
2032
+ type,
2033
+ user_agent,
2034
+ user_email
2035
+ } = log;
2036
+ return {
2037
+ event_id,
2038
+ created_at,
2039
+ ip_address,
2040
+ type,
2041
+ user_agent,
2042
+ user_email
2043
+ };
2044
+ })
2045
+ }, null, 2);
2046
+ } catch (e) {
2047
+ logger.logger.error('There was a problem converting the logs to JSON, please try without the `--json` flag');
2048
+ process.exitCode = 1;
1912
2049
  return;
1913
2050
  }
1914
- spinner.stop();
2051
+ logger.logger.log(json);
2052
+ }
2053
+ async function outputAsMarkdown(auditLogs, orgSlug, logType, page, perPage) {
2054
+ try {
2055
+ const table = mdTable(auditLogs, ['event_id', 'created_at', 'type', 'user_email', 'ip_address', 'user_agent']);
2056
+ logger.logger.log(commonTags.stripIndents`
2057
+ # Socket Audit Logs
2058
+
2059
+ These are the Socket.dev audit logs as per requested query.
2060
+ - org: ${orgSlug}
2061
+ - type filter: ${logType || '(none)'}
2062
+ - page: ${page}
2063
+ - per page: ${perPage}
2064
+ - generated: ${new Date().toISOString()}
2065
+
2066
+ ${table}
2067
+ `);
2068
+ } catch (e) {
2069
+ logger.logger.error('There was a problem converting the logs to JSON, please try without the `--json` flag');
2070
+ logger.logger.error(e);
2071
+ process.exitCode = 1;
2072
+ return;
2073
+ }
2074
+ }
2075
+ function mdTable(logs,
2076
+ // This is saying "an array of strings and the strings are a valid key of elements of T"
2077
+ // In turn, T is defined above as the audit log event type from our OpenAPI docs.
2078
+ cols) {
2079
+ // Max col width required to fit all data in that column
2080
+ const cws = cols.map(col => col.length);
2081
+ for (const log of logs) {
2082
+ for (let i = 0; i < cols.length; ++i) {
2083
+ // @ts-ignore
2084
+ const val = log[cols[i] ?? ''] ?? '';
2085
+ cws[i] = Math.max(cws[i] ?? 0, String(val).length);
2086
+ }
2087
+ }
2088
+ let div = '|';
2089
+ for (const cw of cws) div += ' ' + '-'.repeat(cw) + ' |';
2090
+ let header = '|';
2091
+ for (let i = 0; i < cols.length; ++i) header += ' ' + String(cols[i]).padEnd(cws[i] ?? 0, ' ') + ' |';
2092
+ let body = '';
2093
+ for (const log of logs) {
2094
+ body += '|';
2095
+ for (let i = 0; i < cols.length; ++i) {
2096
+ // @ts-ignore
2097
+ const val = log[cols[i] ?? ''] ?? '';
2098
+ body += ' ' + String(val).padEnd(cws[i] ?? 0, ' ') + ' |';
2099
+ }
2100
+ body += '\n';
2101
+ }
2102
+ return [div, header, div, body.trim(), div].filter(s => !!s.trim()).join('\n');
2103
+ }
2104
+ async function outputAsPrint(auditLogs, orgSlug, logType) {
1915
2105
  const data = [];
1916
2106
  const logDetails = {};
1917
- for (const d of result.data.results) {
2107
+ for (const d of auditLogs) {
1918
2108
  const {
1919
2109
  created_at
1920
2110
  } = d;
@@ -1931,11 +2121,42 @@ async function getAuditLog({
1931
2121
  }
1932
2122
  }
1933
2123
  logger.logger.log(logDetails[await prompts.select({
1934
- message: type ? `\n Audit log for: ${orgSlug} with type: ${type}\n` : `\n Audit log for: ${orgSlug}\n`,
2124
+ message: logType ? `\n Audit log for: ${orgSlug} with type: ${logType}\n` : `\n Audit log for: ${orgSlug}\n`,
1935
2125
  choices: data,
1936
2126
  pageSize: 30
1937
2127
  })]);
1938
2128
  }
2129
+ async function getAuditLogWithToken({
2130
+ apiToken,
2131
+ logType,
2132
+ orgSlug,
2133
+ outputKind,
2134
+ page,
2135
+ perPage
2136
+ }) {
2137
+ // Lazily access constants.spinner.
2138
+ const {
2139
+ spinner
2140
+ } = constants;
2141
+ spinner.start(`Looking up audit log for ${orgSlug}`);
2142
+ const socketSdk = await index.setupSdk(apiToken);
2143
+ const result = await handleApiCall(socketSdk.getAuditLogEvents(orgSlug, {
2144
+ outputJson: outputKind === 'json',
2145
+ // I'm not sure this is used at all
2146
+ outputMarkdown: outputKind === 'markdown',
2147
+ // I'm not sure this is used at all
2148
+ orgSlug,
2149
+ type: logType,
2150
+ page,
2151
+ per_page: perPage
2152
+ }), `Looking up audit log for ${orgSlug}\n`);
2153
+ if (!result.success) {
2154
+ handleUnsuccessfulApiResponse('getAuditLogEvents', result, spinner);
2155
+ return;
2156
+ }
2157
+ spinner.stop();
2158
+ return result.data;
2159
+ }
1939
2160
 
1940
2161
  const {
1941
2162
  DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$w
@@ -1991,33 +2212,36 @@ async function run$x(argv, importMeta, {
1991
2212
  importMeta,
1992
2213
  parentName
1993
2214
  });
1994
- const type = String(cli.flags['type'] || '');
2215
+ const {
2216
+ json,
2217
+ markdown,
2218
+ page,
2219
+ perPage,
2220
+ type
2221
+ } = cli.flags;
2222
+ const logType = String(type || '');
1995
2223
  const [orgSlug = ''] = cli.input;
1996
2224
  if (!orgSlug) {
1997
2225
  // Use exit status of 2 to indicate incorrect usage, generally invalid
1998
2226
  // options or missing arguments.
1999
2227
  // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
2000
2228
  process.exitCode = 2;
2001
- logger.logger.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
2002
- - Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n`);
2229
+ logger.logger.error(commonTags.stripIndents`
2230
+ ${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
2231
+ - Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}
2232
+ `);
2003
2233
  return;
2004
2234
  }
2005
2235
  if (cli.flags['dryRun']) {
2006
2236
  logger.logger.log(DRY_RUN_BAIL_TEXT$w);
2007
2237
  return;
2008
2238
  }
2009
- const apiToken = index.getDefaultToken();
2010
- if (!apiToken) {
2011
- throw new index.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
2012
- }
2013
2239
  await getAuditLog({
2014
- apiToken,
2015
2240
  orgSlug,
2016
- outputJson: Boolean(cli.flags['json']),
2017
- outputMarkdown: Boolean(cli.flags['markdown']),
2018
- page: Number(cli.flags['page'] || 0),
2019
- perPage: Number(cli.flags['perPage'] || 0),
2020
- type: type.charAt(0).toUpperCase() + type.slice(1)
2241
+ outputKind: json ? 'json' : markdown ? 'markdown' : 'print',
2242
+ page: Number(page || 0),
2243
+ perPage: Number(perPage || 0),
2244
+ logType: logType.charAt(0).toUpperCase() + logType.slice(1)
2021
2245
  });
2022
2246
  }
2023
2247
 
@@ -2204,8 +2428,11 @@ async function run$w(argv, importMeta, {
2204
2428
  //
2205
2429
  //
2206
2430
  // if (cli.input.length)
2207
- // logger.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
2208
- // - Unexpected arguments\n
2431
+ // logger.error(
2432
+ // stripIndents`
2433
+ // ${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:
2434
+ //
2435
+ // - Unexpected arguments
2209
2436
  // `)
2210
2437
  // config.help(parentName, config)
2211
2438
  // return
@@ -3318,9 +3545,11 @@ async function run$p(argv, importMeta, {
3318
3545
  // options or missing arguments.
3319
3546
  // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
3320
3547
  process.exitCode = 2;
3321
- logger.logger.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
3322
- - The DIR arg is required ${!target ? colors.red('(missing!)') : target === '-' ? colors.red('(stdin is not supported)') : colors.green('(ok)')}\n
3323
- - Can only accept one DIR (make sure to escape spaces!) ${cli.input.length > 1 ? colors.red(`(received ${cli.input.length}!)`) : colors.green('(ok)')}\n`);
3548
+ logger.logger.error(commonTags.stripIndents`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:
3549
+
3550
+ - The DIR arg is required ${!target ? colors.red('(missing!)') : target === '-' ? colors.red('(stdin is not supported)') : colors.green('(ok)')}
3551
+
3552
+ - Can only accept one DIR (make sure to escape spaces!) ${cli.input.length > 1 ? colors.red(`(received ${cli.input.length}!)`) : colors.green('(ok)')}`);
3324
3553
  return;
3325
3554
  }
3326
3555
  let bin;
@@ -3552,9 +3781,11 @@ async function run$o(argv, importMeta, {
3552
3781
  // options or missing arguments.
3553
3782
  // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
3554
3783
  process.exitCode = 2;
3555
- logger.logger.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
3556
- - The DIR or FILE arg is required ${!target ? colors.red('(missing!)') : target === '-' ? colors.red('(stdin is not supported)') : colors.green('(ok)')}\n
3557
- - Can only accept one DIR or FILE (make sure to escape spaces!) ${cli.input.length > 1 ? colors.red(`(received ${cli.input.length}!)`) : colors.green('(ok)')}\n`);
3784
+ logger.logger.error(commonTags.stripIndents`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:
3785
+
3786
+ - The DIR or FILE arg is required ${!target ? colors.red('(missing!)') : target === '-' ? colors.red('(stdin is not supported)') : colors.green('(ok)')}
3787
+
3788
+ - Can only accept one DIR or FILE (make sure to escape spaces!) ${cli.input.length > 1 ? colors.red(`(received ${cli.input.length}!)`) : colors.green('(ok)')}`);
3558
3789
  return;
3559
3790
  }
3560
3791
  let bin = 'sbt';
@@ -3810,9 +4041,11 @@ async function run$m(argv, importMeta, {
3810
4041
  // options or missing arguments.
3811
4042
  // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
3812
4043
  process.exitCode = 2;
3813
- logger.logger.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
3814
- - The DIR arg is required ${!target ? colors.red('(missing!)') : target === '-' ? colors.red('(stdin is not supported)') : colors.green('(ok)')}\n
3815
- - Can only accept one DIR (make sure to escape spaces!) ${cli.input.length > 1 ? colors.red(`(received ${cli.input.length}!)`) : colors.green('(ok)')}\n`);
4044
+ logger.logger.error(commonTags.stripIndents`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:
4045
+
4046
+ - The DIR arg is required ${!target ? colors.red('(missing!)') : target === '-' ? colors.red('(stdin is not supported)') : colors.green('(ok)')}
4047
+
4048
+ - Can only accept one DIR (make sure to escape spaces!) ${cli.input.length > 1 ? colors.red(`(received ${cli.input.length}!)`) : colors.green('(ok)')}`);
3816
4049
  return;
3817
4050
  }
3818
4051
  let bin;
@@ -5210,9 +5443,10 @@ async function run$g(argv, importMeta, {
5210
5443
  // options or missing arguments.
5211
5444
  // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
5212
5445
  process.exitCode = 2;
5213
- logger.logger.error(`
5214
- ${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
5215
- - The json and markdown flags cannot be both set, pick one
5446
+ logger.logger.error(commonTags.stripIndents`
5447
+ ${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:
5448
+
5449
+ - The json and markdown flags cannot be both set, pick one
5216
5450
  `);
5217
5451
  return;
5218
5452
  }
@@ -5450,11 +5684,12 @@ function formatReportDataOutput(reportId, data, commandName, outputJson, outputM
5450
5684
  logger.logger.log(JSON.stringify(data, undefined, 2));
5451
5685
  } else {
5452
5686
  const format = new index.ColorOrMarkdown(outputMarkdown);
5453
- logger.logger.log('\nDetailed info on socket.dev: ' + format.hyperlink(reportId, data.url, {
5687
+ logger.logger.log(commonTags.stripIndents`
5688
+ Detailed info on socket.dev: ${format.hyperlink(reportId, data.url, {
5454
5689
  fallbackToUrl: true
5455
- }));
5690
+ })}`);
5456
5691
  if (!outputMarkdown) {
5457
- logger.logger.log(colors.dim(`\nOr rerun ${colors.italic(commandName)} using the ${colors.italic('--json')} flag to get full JSON output`));
5692
+ logger.logger.log(colors.dim(`Or rerun ${colors.italic(commandName)} using the ${colors.italic('--json')} flag to get full JSON output`));
5458
5693
  }
5459
5694
  }
5460
5695
  if (strict && !data.healthy) {
@@ -5623,9 +5858,11 @@ async function run$c(argv, importMeta, {
5623
5858
  // options or missing arguments.
5624
5859
  // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
5625
5860
  process.exitCode = 2;
5626
- logger.logger.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
5627
- - Need at least one report ID ${!reportId ? colors.red('(missing!)') : colors.green('(ok)')}\n
5628
- - Can only handle a single report ID ${extraInput.length < 2 ? colors.red(`(received ${extraInput.length}!)`) : colors.green('(ok)')}\n`);
5861
+ logger.logger.error(commonTags.stripIndents`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:
5862
+
5863
+ - Need at least one report ID ${!reportId ? colors.red('(missing!)') : colors.green('(ok)')}
5864
+
5865
+ - Can only handle a single report ID ${extraInput.length < 2 ? colors.red(`(received ${extraInput.length}!)`) : colors.green('(ok)')}`);
5629
5866
  return;
5630
5867
  }
5631
5868
  if (cli.flags['dryRun']) {
@@ -5766,9 +6003,11 @@ async function run$b(argv, importMeta, {
5766
6003
  // options or missing arguments.
5767
6004
  // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
5768
6005
  process.exitCode = 2;
5769
- logger.logger.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
5770
- - Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n
5771
- - Repository name using --repoName ${!repoName ? colors.red('(missing!)') : typeof repoName !== 'string' ? colors.red('(invalid!)') : colors.green('(ok)')}\n`);
6006
+ logger.logger.error(commonTags.stripIndents`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:
6007
+
6008
+ - Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}
6009
+
6010
+ - Repository name using --repoName ${!repoName ? colors.red('(missing!)') : typeof repoName !== 'string' ? colors.red('(invalid!)') : colors.green('(ok)')}`);
5772
6011
  return;
5773
6012
  }
5774
6013
  if (cli.flags['dryRun']) {
@@ -5848,10 +6087,13 @@ async function run$a(argv, importMeta, {
5848
6087
  // options or missing arguments.
5849
6088
  // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
5850
6089
  process.exitCode = 2;
5851
- logger.logger.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
5852
- - Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n
5853
- - Repository name as the second argument ${!repoName ? colors.red('(missing!)') : typeof repoName !== 'string' ? colors.red('(invalid!)') : colors.green('(ok)')}\n
5854
- - At least one TARGET (e.g. \`.\` or \`./package.json\`\n`);
6090
+ logger.logger.error(commonTags.stripIndents`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:
6091
+
6092
+ - Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}
6093
+
6094
+ - Repository name as the second argument ${!repoName ? colors.red('(missing!)') : typeof repoName !== 'string' ? colors.red('(invalid!)') : colors.green('(ok)')}
6095
+
6096
+ - At least one TARGET (e.g. \`.\` or \`./package.json\``);
5855
6097
  return;
5856
6098
  }
5857
6099
  if (cli.flags['dryRun']) {
@@ -5993,9 +6235,11 @@ async function run$9(argv, importMeta, {
5993
6235
  // options or missing arguments.
5994
6236
  // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
5995
6237
  process.exitCode = 2;
5996
- logger.logger.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
5997
- - Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n
5998
- - At least one TARGET (e.g. \`.\` or \`./package.json\`\n`);
6238
+ logger.logger.error(commonTags.stripIndents`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:
6239
+
6240
+ - Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}
6241
+
6242
+ - At least one TARGET (e.g. \`.\` or \`./package.json\``);
5999
6243
  return;
6000
6244
  }
6001
6245
  if (cli.flags['dryRun']) {
@@ -6125,10 +6369,13 @@ async function run$8(argv, importMeta, {
6125
6369
  // options or missing arguments.
6126
6370
  // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
6127
6371
  process.exitCode = 2;
6128
- logger.logger.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
6129
- - Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n
6130
- - Repository name using --repoName ${!repoName ? colors.red('(missing!)') : typeof repoName !== 'string' ? colors.red('(invalid!)') : colors.green('(ok)')}\n
6131
- - At least one TARGET (e.g. \`.\` or \`./package.json\`\n`);
6372
+ logger.logger.error(commonTags.stripIndents`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:
6373
+
6374
+ - Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}
6375
+
6376
+ - Repository name using --repoName ${!repoName ? colors.red('(missing!)') : typeof repoName !== 'string' ? colors.red('(invalid!)') : colors.green('(ok)')}
6377
+
6378
+ - At least one TARGET (e.g. \`.\` or \`./package.json\``);
6132
6379
  return;
6133
6380
  }
6134
6381
  if (cli.flags['dryRun']) {
@@ -6235,9 +6482,13 @@ async function run$7(argv, importMeta, {
6235
6482
  // options or missing arguments.
6236
6483
  // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
6237
6484
  process.exitCode = 2;
6238
- logger.logger.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
6239
- - Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n
6240
- - Repository name using --repoName ${!repoName ? colors.red('(missing!)') : typeof repoName !== 'string' ? colors.red('(invalid!)') : colors.green('(ok)')}\n`);
6485
+ logger.logger.error(commonTags.stripIndents`
6486
+ ${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:
6487
+
6488
+ - Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}
6489
+
6490
+ - Repository name using --repoName ${!repoName ? colors.red('(missing!)') : typeof repoName !== 'string' ? colors.red('(invalid!)') : colors.green('(ok)')}
6491
+ `);
6241
6492
  return;
6242
6493
  }
6243
6494
  if (cli.flags['dryRun']) {
@@ -6493,14 +6744,19 @@ async function createFullScan({
6493
6744
  // options or missing arguments.
6494
6745
  // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
6495
6746
  process$1.exitCode = 2;
6496
- logger.logger.error(`
6497
- ${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
6498
- - Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n
6499
- - Repository name using --repo ${!repoName ? colors.red('(missing!)') : colors.green('(ok)')}\n
6500
- - Branch name using --branch ${!branchName ? colors.red('(missing!)') : colors.green('(ok)')}\n
6501
- - At least one TARGET (e.g. \`.\` or \`./package.json\`) ${!packagePaths.length ? colors.red(targets.length > 0 ? '(TARGET' + (targets.length ? 's' : '') + ' contained no matching/supported files!)' : '(missing)') : colors.green('(ok)')}\n
6502
- ${!apiToken ? 'Note: was unable to make suggestions because no API Token was found; this would make command fail regardless\n' : ''}
6503
- `);
6747
+ logger.logger.error(commonTags.stripIndents`
6748
+ ${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:
6749
+
6750
+ - Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}
6751
+
6752
+ - Repository name using --repo ${!repoName ? colors.red('(missing!)') : colors.green('(ok)')}
6753
+
6754
+ - Branch name using --branch ${!branchName ? colors.red('(missing!)') : colors.green('(ok)')}
6755
+
6756
+ - At least one TARGET (e.g. \`.\` or \`./package.json\`) ${!packagePaths.length ? colors.red(targets.length > 0 ? '(TARGET' + (targets.length ? 's' : '') + ' contained no matching/supported files!)' : '(missing)') : colors.green('(ok)')}
6757
+
6758
+ ${!apiToken ? 'Note: was unable to make suggestions because no API Token was found; this would make command fail regardless' : ''}
6759
+ `);
6504
6760
  return;
6505
6761
  }
6506
6762
  if (updatedInput) {
@@ -6662,13 +6918,18 @@ async function run$6(argv, importMeta, {
6662
6918
  // options or missing arguments.
6663
6919
  // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
6664
6920
  process$1.exitCode = 2;
6665
- logger.logger.error(`
6666
- ${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
6667
- - Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n
6668
- - Repository name using --repo ${!repoName ? colors.red('(missing!)') : colors.green('(ok)')}\n
6669
- - Branch name using --branch ${!branchName ? colors.red('(missing!)') : colors.green('(ok)')}\n
6670
- - At least one TARGET (e.g. \`.\` or \`./package.json\`) ${!targets.length ? '(missing)' : colors.green('(ok)')}\n
6671
- (Additionally, no API Token was set so we cannot auto-discover these details)\n
6921
+ logger.logger.error(commonTags.stripIndents`
6922
+ ${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:
6923
+
6924
+ - Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}
6925
+
6926
+ - Repository name using --repo ${!repoName ? colors.red('(missing!)') : colors.green('(ok)')}
6927
+
6928
+ - Branch name using --branch ${!branchName ? colors.red('(missing!)') : colors.green('(ok)')}
6929
+
6930
+ - At least one TARGET (e.g. \`.\` or \`./package.json\`) ${!targets.length ? '(missing)' : colors.green('(ok)')}
6931
+
6932
+ (Additionally, no API Token was set so we cannot auto-discover these details)
6672
6933
  `);
6673
6934
  return;
6674
6935
  }
@@ -6752,9 +7013,11 @@ async function run$5(argv, importMeta, {
6752
7013
  // options or missing arguments.
6753
7014
  // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
6754
7015
  process.exitCode = 2;
6755
- logger.logger.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
6756
- - Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n
6757
- - Full Scan ID to delete as second argument ${!fullScanId ? colors.red('(missing!)') : colors.green('(ok)')}\n`);
7016
+ logger.logger.error(commonTags.stripIndents`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:
7017
+
7018
+ - Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}
7019
+
7020
+ - Full Scan ID to delete as second argument ${!fullScanId ? colors.red('(missing!)') : colors.green('(ok)')}`);
6758
7021
  return;
6759
7022
  }
6760
7023
  if (cli.flags['dryRun']) {
@@ -6890,8 +7153,9 @@ async function run$4(argv, importMeta, {
6890
7153
  // options or missing arguments.
6891
7154
  // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
6892
7155
  process.exitCode = 2;
6893
- logger.logger.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
6894
- - Org name as the argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n`);
7156
+ logger.logger.error(commonTags.stripIndents`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:
7157
+
7158
+ - Org name as the argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}`);
6895
7159
  return;
6896
7160
  }
6897
7161
  if (cli.flags['dryRun']) {
@@ -6975,9 +7239,11 @@ async function run$3(argv, importMeta, {
6975
7239
  // options or missing arguments.
6976
7240
  // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
6977
7241
  process.exitCode = 2;
6978
- logger.logger.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
6979
- - Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n
6980
- - Full Scan ID to inspect as second argument ${!fullScanId ? colors.red('(missing!)') : colors.green('(ok)')}\n`);
7242
+ logger.logger.error(commonTags.stripIndents`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:
7243
+
7244
+ - Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}
7245
+
7246
+ - Full Scan ID to inspect as second argument ${!fullScanId ? colors.red('(missing!)') : colors.green('(ok)')}`);
6981
7247
  return;
6982
7248
  }
6983
7249
  if (cli.flags['dryRun']) {
@@ -7051,9 +7317,13 @@ async function run$2(argv, importMeta, {
7051
7317
  // options or missing arguments.
7052
7318
  // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
7053
7319
  process.exitCode = 2;
7054
- logger.logger.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
7055
- - Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}\n
7056
- - Full Scan ID to fetch as second argument ${!fullScanId ? colors.red('(missing!)') : colors.green('(ok)')}\n`);
7320
+ logger.logger.error(commonTags.stripIndents`
7321
+ ${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:
7322
+
7323
+ - Org name as the first argument ${!orgSlug ? colors.red('(missing!)') : colors.green('(ok)')}
7324
+
7325
+ - Full Scan ID to fetch as second argument ${!fullScanId ? colors.red('(missing!)') : colors.green('(ok)')}
7326
+ `);
7057
7327
  return;
7058
7328
  }
7059
7329
  if (cli.flags['dryRun']) {
@@ -7252,7 +7522,7 @@ function addSocketWrapper(file) {
7252
7522
  }
7253
7523
  // TODO: pretty sure you need to source the file or restart
7254
7524
  // any terminal session before changes are reflected.
7255
- logger.logger.log(`
7525
+ logger.logger.log(commonTags.stripIndents`
7256
7526
  The alias was added to ${file}. Running 'npm install' will now be wrapped in Socket's "safe npm" 🎉
7257
7527
  If you want to disable it at any time, run \`socket wrapper --disable\`
7258
7528
  `);
@@ -7405,8 +7675,11 @@ async function run(argv, importMeta, {
7405
7675
  // options or missing arguments.
7406
7676
  // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
7407
7677
  process.exitCode = 2;
7408
- logger.logger.error(`${colors.bgRed(colors.white('Input error'))}: Please provide the required flags:\n
7409
- - Must use --enabled or --disabled\n`);
7678
+ logger.logger.error(commonTags.stripIndents`
7679
+ ${colors.bgRed(colors.white('Input error'))}: Please provide the required flags:
7680
+
7681
+ - Must use --enabled or --disabled
7682
+ `);
7410
7683
  return;
7411
7684
  }
7412
7685
  if (cli.flags['dryRun']) {
@@ -7515,5 +7788,5 @@ void (async () => {
7515
7788
  await index.captureException(e);
7516
7789
  }
7517
7790
  })();
7518
- //# debugId=f23df080-286e-4174-a361-db1fa42ece1
7791
+ //# debugId=b11caea8-68eb-4110-977e-c8cc2d1f4464
7519
7792
  //# sourceMappingURL=cli.js.map