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