@datadog/datadog-ci 3.1.0 → 3.3.0

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.
Files changed (168) hide show
  1. package/README.md +3 -0
  2. package/dist/__tests__/cli.test.js +1 -0
  3. package/dist/__tests__/cli.test.js.map +1 -1
  4. package/dist/commands/coverage/__tests__/upload.test.js +48 -80
  5. package/dist/commands/coverage/__tests__/upload.test.js.map +1 -1
  6. package/dist/commands/coverage/__tests__/utils.test.js +4 -14
  7. package/dist/commands/coverage/__tests__/utils.test.js.map +1 -1
  8. package/dist/commands/coverage/renderer.d.ts +0 -2
  9. package/dist/commands/coverage/renderer.js +1 -9
  10. package/dist/commands/coverage/renderer.js.map +1 -1
  11. package/dist/commands/coverage/upload.d.ts +2 -3
  12. package/dist/commands/coverage/upload.js +29 -88
  13. package/dist/commands/coverage/upload.js.map +1 -1
  14. package/dist/commands/coverage/utils.d.ts +0 -1
  15. package/dist/commands/coverage/utils.js +11 -35
  16. package/dist/commands/coverage/utils.js.map +1 -1
  17. package/dist/commands/elf-symbols/__tests__/elf.test.js +12 -9
  18. package/dist/commands/elf-symbols/__tests__/elf.test.js.map +1 -1
  19. package/dist/commands/elf-symbols/__tests__/upload.test.js +9 -5
  20. package/dist/commands/elf-symbols/__tests__/upload.test.js.map +1 -1
  21. package/dist/commands/elf-symbols/elf.d.ts +2 -11
  22. package/dist/commands/elf-symbols/elf.js +52 -68
  23. package/dist/commands/elf-symbols/elf.js.map +1 -1
  24. package/dist/commands/elf-symbols/upload.js +3 -3
  25. package/dist/commands/elf-symbols/upload.js.map +1 -1
  26. package/dist/commands/junit/__tests__/upload.test.js +114 -65
  27. package/dist/commands/junit/__tests__/upload.test.js.map +1 -1
  28. package/dist/commands/junit/renderer.d.ts +2 -2
  29. package/dist/commands/junit/renderer.js +3 -1
  30. package/dist/commands/junit/renderer.js.map +1 -1
  31. package/dist/commands/junit/upload.d.ts +2 -0
  32. package/dist/commands/junit/upload.js +41 -37
  33. package/dist/commands/junit/upload.js.map +1 -1
  34. package/dist/commands/junit/utils.d.ts +0 -1
  35. package/dist/commands/junit/utils.js +1 -11
  36. package/dist/commands/junit/utils.js.map +1 -1
  37. package/dist/commands/pe-symbols/__tests__/pe.test.d.ts +1 -0
  38. package/dist/commands/pe-symbols/__tests__/pe.test.js +81 -0
  39. package/dist/commands/pe-symbols/__tests__/pe.test.js.map +1 -0
  40. package/dist/commands/pe-symbols/cli.d.ts +1 -0
  41. package/dist/commands/pe-symbols/cli.js +5 -0
  42. package/dist/commands/pe-symbols/cli.js.map +1 -0
  43. package/dist/commands/pe-symbols/helpers.d.ts +4 -0
  44. package/dist/commands/pe-symbols/helpers.js +30 -0
  45. package/dist/commands/pe-symbols/helpers.js.map +1 -0
  46. package/dist/commands/pe-symbols/interfaces.d.ts +17 -0
  47. package/dist/commands/pe-symbols/interfaces.js +7 -0
  48. package/dist/commands/pe-symbols/interfaces.js.map +1 -0
  49. package/dist/commands/pe-symbols/pe-constants.d.ts +51 -0
  50. package/dist/commands/pe-symbols/pe-constants.js +160 -0
  51. package/dist/commands/pe-symbols/pe-constants.js.map +1 -0
  52. package/dist/commands/pe-symbols/pe.d.ts +35 -0
  53. package/dist/commands/pe-symbols/pe.js +248 -0
  54. package/dist/commands/pe-symbols/pe.js.map +1 -0
  55. package/dist/commands/pe-symbols/renderer.d.ts +19 -0
  56. package/dist/commands/pe-symbols/renderer.js +87 -0
  57. package/dist/commands/pe-symbols/renderer.js.map +1 -0
  58. package/dist/commands/pe-symbols/upload.d.ts +32 -0
  59. package/dist/commands/pe-symbols/upload.js +412 -0
  60. package/dist/commands/pe-symbols/upload.js.map +1 -0
  61. package/dist/commands/sarif/__tests__/upload.test.js +79 -6
  62. package/dist/commands/sarif/__tests__/upload.test.js.map +1 -1
  63. package/dist/commands/sarif/renderer.d.ts +1 -0
  64. package/dist/commands/sarif/renderer.js +4 -2
  65. package/dist/commands/sarif/renderer.js.map +1 -1
  66. package/dist/commands/sarif/upload.d.ts +1 -0
  67. package/dist/commands/sarif/upload.js +3 -2
  68. package/dist/commands/sarif/upload.js.map +1 -1
  69. package/dist/commands/sbom/__tests__/payload.test.js +157 -26
  70. package/dist/commands/sbom/__tests__/payload.test.js.map +1 -1
  71. package/dist/commands/sbom/constants.d.ts +2 -0
  72. package/dist/commands/sbom/constants.js +4 -1
  73. package/dist/commands/sbom/constants.js.map +1 -1
  74. package/dist/commands/sbom/payload.js +44 -0
  75. package/dist/commands/sbom/payload.js.map +1 -1
  76. package/dist/commands/sbom/types.d.ts +4 -0
  77. package/dist/commands/sbom/upload.d.ts +1 -0
  78. package/dist/commands/sbom/upload.js +3 -2
  79. package/dist/commands/sbom/upload.js.map +1 -1
  80. package/dist/commands/synthetics/__tests__/api.test.js +2 -2
  81. package/dist/commands/synthetics/__tests__/api.test.js.map +1 -1
  82. package/dist/commands/synthetics/__tests__/batch.test.js +38 -37
  83. package/dist/commands/synthetics/__tests__/batch.test.js.map +1 -1
  84. package/dist/commands/synthetics/__tests__/build-and-test.test.d.ts +1 -0
  85. package/dist/commands/synthetics/__tests__/build-and-test.test.js +133 -0
  86. package/dist/commands/synthetics/__tests__/build-and-test.test.js.map +1 -0
  87. package/dist/commands/synthetics/__tests__/cli.test.js +83 -47
  88. package/dist/commands/synthetics/__tests__/cli.test.js.map +1 -1
  89. package/dist/commands/synthetics/__tests__/deploy-tests-lib.test.js +2 -2
  90. package/dist/commands/synthetics/__tests__/deploy-tests-lib.test.js.map +1 -1
  91. package/dist/commands/synthetics/__tests__/import-tests-lib.test.js +4 -4
  92. package/dist/commands/synthetics/__tests__/import-tests-lib.test.js.map +1 -1
  93. package/dist/commands/synthetics/__tests__/multilocator.test.js +13 -3
  94. package/dist/commands/synthetics/__tests__/multilocator.test.js.map +1 -1
  95. package/dist/commands/synthetics/__tests__/test.test.js +6 -7
  96. package/dist/commands/synthetics/__tests__/test.test.js.map +1 -1
  97. package/dist/commands/synthetics/__tests__/tunnel/websocket.test.js +1 -1
  98. package/dist/commands/synthetics/__tests__/tunnel/websocket.test.js.map +1 -1
  99. package/dist/commands/synthetics/__tests__/utils/public.test.js +10 -9
  100. package/dist/commands/synthetics/__tests__/utils/public.test.js.map +1 -1
  101. package/dist/commands/synthetics/api.js +2 -2
  102. package/dist/commands/synthetics/api.js.map +1 -1
  103. package/dist/commands/synthetics/base-command.d.ts +29 -0
  104. package/dist/commands/synthetics/base-command.js +125 -0
  105. package/dist/commands/synthetics/base-command.js.map +1 -0
  106. package/dist/commands/synthetics/batch.d.ts +1 -0
  107. package/dist/commands/synthetics/batch.js +3 -3
  108. package/dist/commands/synthetics/batch.js.map +1 -1
  109. package/dist/commands/synthetics/build-and-test.d.ts +8 -0
  110. package/dist/commands/synthetics/build-and-test.js +102 -0
  111. package/dist/commands/synthetics/build-and-test.js.map +1 -0
  112. package/dist/commands/synthetics/deploy-tests-command.d.ts +8 -16
  113. package/dist/commands/synthetics/deploy-tests-command.js +19 -91
  114. package/dist/commands/synthetics/deploy-tests-command.js.map +1 -1
  115. package/dist/commands/synthetics/import-tests-command.d.ts +6 -14
  116. package/dist/commands/synthetics/import-tests-command.js +15 -83
  117. package/dist/commands/synthetics/import-tests-command.js.map +1 -1
  118. package/dist/commands/synthetics/index.d.ts +1 -1
  119. package/dist/commands/synthetics/index.js +6 -6
  120. package/dist/commands/synthetics/index.js.map +1 -1
  121. package/dist/commands/synthetics/interfaces.d.ts +5 -2
  122. package/dist/commands/synthetics/multilocator.d.ts +0 -1
  123. package/dist/commands/synthetics/multilocator.js +7 -17
  124. package/dist/commands/synthetics/multilocator.js.map +1 -1
  125. package/dist/commands/synthetics/run-tests-command.d.ts +12 -17
  126. package/dist/commands/synthetics/run-tests-command.js +133 -190
  127. package/dist/commands/synthetics/run-tests-command.js.map +1 -1
  128. package/dist/commands/synthetics/run-tests-lib.d.ts +1 -0
  129. package/dist/commands/synthetics/run-tests-lib.js +8 -4
  130. package/dist/commands/synthetics/run-tests-lib.js.map +1 -1
  131. package/dist/commands/synthetics/test.d.ts +2 -0
  132. package/dist/commands/synthetics/test.js +9 -8
  133. package/dist/commands/synthetics/test.js.map +1 -1
  134. package/dist/commands/synthetics/upload-application-command.d.ts +6 -13
  135. package/dist/commands/synthetics/upload-application-command.js +22 -87
  136. package/dist/commands/synthetics/upload-application-command.js.map +1 -1
  137. package/dist/commands/synthetics/utils/internal.d.ts +2 -0
  138. package/dist/commands/synthetics/utils/internal.js +15 -1
  139. package/dist/commands/synthetics/utils/internal.js.map +1 -1
  140. package/dist/commands/synthetics/utils/public.js +1 -1
  141. package/dist/commands/synthetics/utils/public.js.map +1 -1
  142. package/dist/helpers/__tests__/ci.test.js +49 -0
  143. package/dist/helpers/__tests__/ci.test.js.map +1 -1
  144. package/dist/helpers/__tests__/tags.test.js +59 -0
  145. package/dist/helpers/__tests__/tags.test.js.map +1 -1
  146. package/dist/helpers/ci.d.ts +13 -0
  147. package/dist/helpers/ci.js +23 -1
  148. package/dist/helpers/ci.js.map +1 -1
  149. package/dist/helpers/file-finder.d.ts +17 -0
  150. package/dist/helpers/file-finder.js +138 -0
  151. package/dist/helpers/file-finder.js.map +1 -0
  152. package/dist/helpers/filereader.d.ts +21 -0
  153. package/dist/helpers/filereader.js +59 -0
  154. package/dist/helpers/filereader.js.map +1 -0
  155. package/dist/helpers/git/format-git-span-data.d.ts +1 -1
  156. package/dist/helpers/git/format-git-span-data.js +2 -2
  157. package/dist/helpers/git/format-git-span-data.js.map +1 -1
  158. package/dist/helpers/interfaces.d.ts +2 -1
  159. package/dist/helpers/prompt.d.ts +5 -3
  160. package/dist/helpers/prompt.js +14 -13
  161. package/dist/helpers/prompt.js.map +1 -1
  162. package/dist/helpers/tags.d.ts +1 -1
  163. package/dist/helpers/tags.js +4 -4
  164. package/dist/helpers/tags.js.map +1 -1
  165. package/dist/helpers/utils.d.ts +3 -0
  166. package/dist/helpers/utils.js +34 -1
  167. package/dist/helpers/utils.js.map +1 -1
  168. package/package.json +4 -3
@@ -0,0 +1,248 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.getBuildId = exports.getPEFileMetadata = void 0;
16
+ const fs_1 = __importDefault(require("fs"));
17
+ const filereader_1 = require("../../helpers/filereader");
18
+ const pe_constants_1 = require("./pe-constants");
19
+ const getArchitecture = (machine) => {
20
+ let architecture = pe_constants_1.MachineArchitecture.unknown;
21
+ if (machine === pe_constants_1.IMAGE_FILE_MACHINE_I386) {
22
+ architecture = pe_constants_1.MachineArchitecture.x86;
23
+ }
24
+ else if (machine === pe_constants_1.IMAGE_FILE_MACHINE_AMD64) {
25
+ architecture = pe_constants_1.MachineArchitecture.x64;
26
+ }
27
+ else if (machine === pe_constants_1.IMAGE_FILE_MACHINE_ARM32) {
28
+ architecture = pe_constants_1.MachineArchitecture.Arm32;
29
+ }
30
+ else if (machine === pe_constants_1.IMAGE_FILE_MACHINE_ARM64) {
31
+ architecture = pe_constants_1.MachineArchitecture.Arm64;
32
+ }
33
+ return architecture;
34
+ };
35
+ const readPEHeader = (reader) => __awaiter(void 0, void 0, void 0, function* () {
36
+ const result = {
37
+ isPE: false,
38
+ };
39
+ result.peHeader = {
40
+ peHeaderOffset: 0,
41
+ is64: false,
42
+ architecture: pe_constants_1.MachineArchitecture.unknown,
43
+ numberOfSections: 0,
44
+ buildTime: '',
45
+ sectionHeadersOffset: 0,
46
+ };
47
+ try {
48
+ // read the DOS header to find the offset to the PE header
49
+ const dosHeaderBuffer = yield reader.read(pe_constants_1.DOS_HEADER_SIZE);
50
+ const dosMagic = dosHeaderBuffer.readInt16LE(0);
51
+ if (dosMagic !== pe_constants_1.IMAGE_DOS_SIGNATURE) {
52
+ result.isPE = false;
53
+ result.error = Error('Invalid DOS header');
54
+ return result;
55
+ }
56
+ const peHeaderOffset = dosHeaderBuffer.readUint32LE(pe_constants_1.DOS_HEADER_LFANEW_OFFSET);
57
+ result.peHeader.peHeaderOffset = peHeaderOffset;
58
+ // look at the PE header now
59
+ const peCommonHeaderBuffer = yield reader.read(pe_constants_1.IMAGE_NT_HEADERS_GENERIC_SIZE, peHeaderOffset);
60
+ // check the signature
61
+ const peSignature = peCommonHeaderBuffer.toString('utf-8', 0, 4);
62
+ if (peSignature !== 'PE\0\0') {
63
+ result.isPE = false;
64
+ result.error = Error('Invalid PE header');
65
+ return result;
66
+ }
67
+ // read the Machine field
68
+ const machine = peCommonHeaderBuffer.readUint16LE(pe_constants_1.IMAGE_NT_HEADERS_GENERIC_MACHINE_OFFSET);
69
+ result.peHeader.architecture = getArchitecture(machine);
70
+ // read the NumberOfSections field
71
+ result.peHeader.numberOfSections = peCommonHeaderBuffer.readUint16LE(pe_constants_1.IMAGE_NT_HEADERS_GENERIC_NUMBEROFSECTIONS_OFFSET);
72
+ // read the build time
73
+ const timestamp = peCommonHeaderBuffer.readUint32LE(pe_constants_1.IMAGE_NT_HEADERS_GENERIC_TIMESTAMP_OFFSET);
74
+ const buildDate = new Date(timestamp * 1000).toUTCString();
75
+ result.peHeader.buildTime = `${buildDate}`;
76
+ // read the Magic field
77
+ const magic = peCommonHeaderBuffer.readUint16LE(pe_constants_1.IMAGE_NT_HEADERS_GENERIC_MAGIC_OFFSET);
78
+ result.peHeader.is64 = magic === pe_constants_1.IMAGE_NT_OPTIONAL_HDR64_MAGIC;
79
+ result.peHeader.sectionHeadersOffset = result.peHeader.is64 ? pe_constants_1.IMAGE_NT_HEADERS64_SIZE : pe_constants_1.IMAGE_NT_HEADERS32_SIZE;
80
+ result.isPE = true;
81
+ }
82
+ catch (error) {
83
+ // console.log(error)
84
+ if (error instanceof Error) {
85
+ result.error = error;
86
+ }
87
+ else {
88
+ throw error;
89
+ }
90
+ }
91
+ return result;
92
+ });
93
+ const getSectionHeaders = (reader, peHeader) => __awaiter(void 0, void 0, void 0, function* () {
94
+ const sections = new Array(peHeader.numberOfSections);
95
+ const sectionHeadersOffset = peHeader.peHeaderOffset + peHeader.sectionHeadersOffset;
96
+ const sectionsBuffer = yield reader.read(peHeader.numberOfSections * pe_constants_1.IMAGE_SECTION_HEADER_SIZE, sectionHeadersOffset);
97
+ let sectionOffset = 0;
98
+ for (let i = 0; i < peHeader.numberOfSections; i++) {
99
+ // the name is at the beginning of the section header
100
+ let name = '';
101
+ for (let j = 0; j < pe_constants_1.IMAGE_SHORT_NAME_SIZE; j++) {
102
+ if (sectionsBuffer[sectionOffset + j] === 0) {
103
+ break;
104
+ }
105
+ name += String.fromCharCode(sectionsBuffer[sectionOffset + j]);
106
+ }
107
+ const virtualSize = sectionsBuffer.readUInt32LE(sectionOffset + pe_constants_1.IMAGE_SECTION_HEADER_VIRTUALSIZE_OFFSET);
108
+ const virtualAddress = sectionsBuffer.readUInt32LE(sectionOffset + pe_constants_1.IMAGE_SECTION_HEADER_VIRTUALADDRESS_OFFSET);
109
+ const pointerToRawData = sectionsBuffer.readUInt32LE(sectionOffset + pe_constants_1.IMAGE_SECTION_HEADER_POINTERTORAWDATA_OFFSET);
110
+ sections[i] = { name, virtualSize, virtualAddress, pointerToRawData };
111
+ sectionOffset += pe_constants_1.IMAGE_SECTION_HEADER_SIZE;
112
+ }
113
+ return sections;
114
+ });
115
+ // from https://github.com/microsoft/clrmd/blob/main/src/Microsoft.Diagnostics.Runtime/Utilities/PEImage/PEImage.cs#L286C1-L303C10
116
+ const rvaToOffset = (virtualAddress, sections) => {
117
+ if (virtualAddress < 4096) {
118
+ return virtualAddress;
119
+ }
120
+ for (const section of sections) {
121
+ if (section.virtualAddress <= virtualAddress && virtualAddress < section.virtualAddress + section.virtualSize) {
122
+ const offset = section.pointerToRawData + (virtualAddress - section.virtualAddress);
123
+ return offset;
124
+ }
125
+ }
126
+ return 0;
127
+ };
128
+ const toHex = (value, length) => {
129
+ return value.toString(16).padStart(length, '0').toUpperCase();
130
+ };
131
+ const getPEFileMetadata = (filename) => __awaiter(void 0, void 0, void 0, function* () {
132
+ var _a;
133
+ const metadata = {
134
+ filename,
135
+ isPE: false,
136
+ arch: pe_constants_1.MachineArchitecture.unknown,
137
+ hasPdbInfo: false,
138
+ pdbAge: 0,
139
+ pdbSig: undefined,
140
+ pdbFilename: '',
141
+ };
142
+ let fileHandle;
143
+ try {
144
+ fileHandle = yield fs_1.default.promises.open(filename, 'r');
145
+ const reader = new filereader_1.FileReader(fileHandle);
146
+ const peHeaderResult = yield readPEHeader(reader);
147
+ if (!peHeaderResult.isPE || peHeaderResult.peHeader === undefined) {
148
+ throw peHeaderResult.error;
149
+ }
150
+ metadata.isPE = true;
151
+ metadata.arch = (_a = peHeaderResult.peHeader) === null || _a === void 0 ? void 0 : _a.architecture;
152
+ // get the DEBUG section
153
+ let debugSectionOffset = 0;
154
+ if (peHeaderResult.peHeader.is64) {
155
+ debugSectionOffset = peHeaderResult.peHeader.peHeaderOffset + pe_constants_1.IMAGE_DATA_DIRECTORY64_OFFSET;
156
+ }
157
+ else {
158
+ debugSectionOffset = peHeaderResult.peHeader.peHeaderOffset + pe_constants_1.IMAGE_DATA_DIRECTORY32_OFFSET;
159
+ }
160
+ debugSectionOffset += pe_constants_1.IMAGE_DIRECTORY_ENTRY_DEBUG * pe_constants_1.IMAGE_DATA_DIRECTORY_SIZE;
161
+ const peCommonHeaderBuffer = yield reader.read(pe_constants_1.IMAGE_DATA_DIRECTORY_SIZE, debugSectionOffset);
162
+ const debugSectionVirtualAddress = peCommonHeaderBuffer.readUInt32LE(pe_constants_1.IMAGE_DATA_DIRECTORY_VIRTUAL_ADDRESS_OFFSET);
163
+ const debugSectionSize = peCommonHeaderBuffer.readUInt32LE(pe_constants_1.IMAGE_DATA_DIRECTORY_SIZE_OFFSET);
164
+ if (debugSectionVirtualAddress === 0) {
165
+ metadata.hasPdbInfo = false;
166
+ return metadata;
167
+ }
168
+ // The "virtual address" needs to be converted into an offset from the begining of the PE file (like peHeaderOffset).
169
+ // To be able to do that, we need to load the array of IMAGE_SECTION_HEADER that follows the optional header;
170
+ // their count is given by the IMAGE_SECTION_HEADER.NumberOfSections field
171
+ const sectionHeaders = yield getSectionHeaders(reader, peHeaderResult.peHeader);
172
+ const debugDirectoriesOffset = rvaToOffset(debugSectionVirtualAddress, sectionHeaders);
173
+ // look inside the different IMAGE_DEBUG_DIRECTORY
174
+ const debugSectionBuffer = yield reader.read(debugSectionSize, debugDirectoriesOffset);
175
+ const entryCount = debugSectionSize / pe_constants_1.IMAGE_DEBUG_DIRECTORY_SIZE;
176
+ let entryOffset = 0;
177
+ for (let i = 0; i < entryCount; i++) {
178
+ const type = debugSectionBuffer.readUInt32LE(entryOffset + pe_constants_1.IMAGE_DEBUG_DIRECTORY_TYPE_OFFSET);
179
+ if (type === pe_constants_1.IMAGE_DEBUG_TYPE_CODEVIEW) {
180
+ const pdbInfoSizeOfData = debugSectionBuffer.readUInt32LE(entryOffset + pe_constants_1.IMAGE_DEBUG_DIRECTORY_SIZEOFDATA_OFFSET);
181
+ const pdbInfoAddress = debugSectionBuffer.readUInt32LE(entryOffset + pe_constants_1.IMAGE_DEBUG_DIRECTORY_ADDRESSOFRAWDATA_OFFSET);
182
+ const pdbInfoOffset = rvaToOffset(pdbInfoAddress, sectionHeaders);
183
+ // we are insterested in the .pdb filename that goes beyond the CV_INFO_PDB70 structure
184
+ const pdbInfoBuffer = yield reader.read(pdbInfoSizeOfData, pdbInfoOffset);
185
+ const pdbSignature = pdbInfoBuffer.readUInt32LE(pe_constants_1.CV_INFO_SIGNATURE_OFFSET);
186
+ if (pdbSignature === pe_constants_1.PDB70_SIGNATURE) {
187
+ metadata.hasPdbInfo = true;
188
+ metadata.pdbAge = pdbInfoBuffer.readUInt32LE(pe_constants_1.CV_INFO_AGE_OFFSET);
189
+ // read the GUID that spans 16 bytes and save it as
190
+ // xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
191
+ metadata.pdbSig =
192
+ toHex(pdbInfoBuffer.readUInt32LE(pe_constants_1.CV_INFO_GUID_OFFSET), 8) +
193
+ '-' +
194
+ toHex(pdbInfoBuffer.readUInt16LE(pe_constants_1.CV_INFO_GUID_OFFSET + 4), 4) +
195
+ '-' +
196
+ toHex(pdbInfoBuffer.readUInt16LE(pe_constants_1.CV_INFO_GUID_OFFSET + 6), 4) +
197
+ '-' +
198
+ toHex(pdbInfoBuffer.readUInt16BE(pe_constants_1.CV_INFO_GUID_OFFSET + 8), 4) +
199
+ '-' +
200
+ toHex(pdbInfoBuffer.readUInt16BE(pe_constants_1.CV_INFO_GUID_OFFSET + 10), 4) +
201
+ toHex(pdbInfoBuffer.readUInt16BE(pe_constants_1.CV_INFO_GUID_OFFSET + 12), 4) +
202
+ toHex(pdbInfoBuffer.readUInt16BE(pe_constants_1.CV_INFO_GUID_OFFSET + 14), 4);
203
+ // read .pdb filename that follows in the structure
204
+ // --> read the characters up to pdbInfoSizeOfData
205
+ // this is not working maybe due to the \ that are replaced by \\
206
+ // const pdbFilename = pdbInfoBuffer.toString('utf-8', CV_INFO_PDB_FILENAME_OFFSET, pdbInfoSizeOfData - CV_INFO_PDB_FILENAME_OFFSET + 1)
207
+ let pdbFilename = '';
208
+ for (let j = pe_constants_1.CV_INFO_PDB_FILENAME_OFFSET; j < pdbInfoSizeOfData; j++) {
209
+ if (pdbInfoBuffer[j] === 0) {
210
+ break;
211
+ }
212
+ pdbFilename += String.fromCharCode(pdbInfoBuffer[j]);
213
+ }
214
+ metadata.pdbFilename = pdbFilename;
215
+ }
216
+ else {
217
+ metadata.hasPdbInfo = false;
218
+ }
219
+ return metadata;
220
+ }
221
+ entryOffset += pe_constants_1.IMAGE_DEBUG_DIRECTORY_SIZE;
222
+ }
223
+ }
224
+ catch (error) {
225
+ // console.log(error)
226
+ if (error instanceof Error) {
227
+ metadata.error = error;
228
+ }
229
+ else {
230
+ throw error;
231
+ }
232
+ }
233
+ finally {
234
+ if (fileHandle) {
235
+ yield fileHandle.close();
236
+ }
237
+ }
238
+ return metadata;
239
+ });
240
+ exports.getPEFileMetadata = getPEFileMetadata;
241
+ const getBuildId = (fileMetadata) => {
242
+ if (fileMetadata.isPE && fileMetadata.hasPdbInfo) {
243
+ return `${fileMetadata.pdbSig}_${fileMetadata.pdbAge}`;
244
+ }
245
+ return '?_?';
246
+ };
247
+ exports.getBuildId = getBuildId;
248
+ //# sourceMappingURL=pe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pe.js","sourceRoot":"","sources":["../../../src/commands/pe-symbols/pe.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4CAAmB;AAEnB,yDAA2D;AAE3D,iDAsCuB;AAwCvB,MAAM,eAAe,GAAG,CAAC,OAAe,EAAuB,EAAE;IAC/D,IAAI,YAAY,GAAwB,kCAAmB,CAAC,OAAO,CAAA;IAEnE,IAAI,OAAO,KAAK,sCAAuB,EAAE;QACvC,YAAY,GAAG,kCAAmB,CAAC,GAAG,CAAA;KACvC;SAAM,IAAI,OAAO,KAAK,uCAAwB,EAAE;QAC/C,YAAY,GAAG,kCAAmB,CAAC,GAAG,CAAA;KACvC;SAAM,IAAI,OAAO,KAAK,uCAAwB,EAAE;QAC/C,YAAY,GAAG,kCAAmB,CAAC,KAAK,CAAA;KACzC;SAAM,IAAI,OAAO,KAAK,uCAAwB,EAAE;QAC/C,YAAY,GAAG,kCAAmB,CAAC,KAAK,CAAA;KACzC;IAED,OAAO,YAAY,CAAA;AACrB,CAAC,CAAA;AAED,MAAM,YAAY,GAAG,CAAO,MAAc,EAA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AC,CAAC,CAAA;oBAEhE,mDAAmD;oBACnD,kDAAkD;oBAClD,iEAAiE;oBACjE,wIAAwI;oBACxI,IAAI,WAAW,GAAG,EAAE,CAAA;oBACpB,KAAK,IAAI,CAAC,GAAG,0CAA2B,EAAE,CAAC,GAAG,iBAAiB,EAAE,CAAC,EAAE,EAAE;wBACpE,IAAI,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE;4BAC1B,MAAK;yBACN;wBACD,WAAW,IAAI,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAA;qBACrD;oBACD,QAAQ,CAAC,WAAW,GAAG,WAAW,CAAA;iBACnC;qBAAM;oBACL,QAAQ,CAAC,UAAU,GAAG,KAAK,CAAA;iBAC5B;gBAED,OAAO,QAAQ,CAAA;aAChB;YAED,WAAW,IAAI,yCAA0B,CAAA;SAC1C;KACF;IAAC,OAAO,KAAK,EAAE;QACd,qBAAqB;QACrB,IAAI,KAAK,YAAY,KAAK,EAAE;YAC1B,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAA;SACvB;aAAM;YACL,MAAM,KAAK,CAAA;SACZ;KACF;YAAS;QACR,IAAI,UAAU,EAAE;YACd,MAAM,UAAU,CAAC,KAAK,EAAE,CAAA;SACzB;KACF;IAED,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA,CAAA;AAvHY,QAAA,iBAAiB,qBAuH7B;AAEM,MAAM,UAAU,GAAG,CAAC,YAA4B,EAAU,EAAE;IACjE,IAAI,YAAY,CAAC,IAAI,IAAI,YAAY,CAAC,UAAU,EAAE;QAChD,OAAO,GAAG,YAAY,CAAC,MAAM,IAAI,YAAY,CAAC,MAAM,EAAE,CAAA;KACvD;IAED,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AANY,QAAA,UAAU,cAMtB"}
@@ -0,0 +1,19 @@
1
+ import { UploadStatus } from '../../helpers/upload';
2
+ import { MappingMetadata } from './interfaces';
3
+ export interface UploadInfo {
4
+ fileType: string;
5
+ location: string;
6
+ platform: string;
7
+ }
8
+ export declare const renderCommandInfo: (dryRun: boolean, symbolsLocations: string[]) => string;
9
+ export declare const renderCommandSummary: (statuses: UploadStatus[], duration: number, dryRun: boolean) => string;
10
+ export declare const renderEventPayload: (payload: string) => string;
11
+ export declare const renderMissingPdbFile: (pdbFilename: string, dllPath: string) => string;
12
+ export declare const renderGitWarning: (errorMessage: string) => string;
13
+ export declare const renderWarning: (errorMessage: string) => string;
14
+ export declare const renderArgumentMissingError: (argumentName: string) => string;
15
+ export declare const renderInvalidSymbolsLocation: (symbolsDirectory: string) => string;
16
+ export declare const renderGeneralizedError: (error: any) => string;
17
+ export declare const renderFailedUpload: (filePath: string, errorMessage: string) => string;
18
+ export declare const renderRetriedUpload: (filePath: string, errorMessage: string, attempt: number) => string;
19
+ export declare const renderUpload: (filePath: string, metadata: MappingMetadata) => string;
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.renderUpload = exports.renderRetriedUpload = exports.renderFailedUpload = exports.renderGeneralizedError = exports.renderInvalidSymbolsLocation = exports.renderArgumentMissingError = exports.renderWarning = exports.renderGitWarning = exports.renderMissingPdbFile = exports.renderEventPayload = exports.renderCommandSummary = exports.renderCommandInfo = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const formatting_1 = require("../../helpers/formatting");
9
+ const upload_1 = require("../../helpers/upload");
10
+ const utils_1 = require("../../helpers/utils");
11
+ const renderCommandInfo = (dryRun, symbolsLocations) => {
12
+ let fullString = '';
13
+ if (dryRun) {
14
+ fullString += chalk_1.default.yellow(`${formatting_1.ICONS.WARNING} DRY-RUN MODE ENABLED. WILL NOT UPLOAD SYMBOLS\n`);
15
+ }
16
+ const startStr = chalk_1.default.green('Starting upload. \n');
17
+ fullString += startStr;
18
+ fullString += chalk_1.default.green(`Uploading symbols from location(s): ${symbolsLocations.join(' ')}\n`);
19
+ fullString += chalk_1.default.green(`After upload is successful symbol files will be processed and ready to use within the next 5 minutes.\n`);
20
+ return fullString;
21
+ };
22
+ exports.renderCommandInfo = renderCommandInfo;
23
+ const renderCommandSummary = (statuses, duration, dryRun) => {
24
+ const results = new Map();
25
+ statuses.forEach((status) => {
26
+ if (!results.has(status)) {
27
+ results.set(status, 0);
28
+ }
29
+ results.set(status, results.get(status) + 1);
30
+ });
31
+ const output = ['', chalk_1.default.bold('Command summary:')];
32
+ if (results.get(upload_1.UploadStatus.Failure)) {
33
+ output.push(chalk_1.default.red(`${formatting_1.ICONS.FAILED} Some symbol files may not been uploaded correctly.`));
34
+ }
35
+ else if (results.get(upload_1.UploadStatus.Skipped)) {
36
+ output.push(chalk_1.default.yellow(`${formatting_1.ICONS.WARNING} Some symbol files have been skipped.`));
37
+ }
38
+ else if (results.get(upload_1.UploadStatus.Success)) {
39
+ if (dryRun) {
40
+ output.push(chalk_1.default.green(`${formatting_1.ICONS.SUCCESS} [DRYRUN] Handled symbol ${(0, utils_1.pluralize)(results.get(upload_1.UploadStatus.Success), 'file', 'files')} with success in ${duration} seconds.`));
41
+ }
42
+ else {
43
+ output.push(chalk_1.default.green(`${formatting_1.ICONS.SUCCESS} Uploaded symbol ${(0, utils_1.pluralize)(results.get(upload_1.UploadStatus.Success), 'file', 'files')} in ${duration} seconds.`));
44
+ }
45
+ }
46
+ else {
47
+ output.push(chalk_1.default.yellow(`${formatting_1.ICONS.WARNING} No actions were taken. Did you specify the correct path?`));
48
+ }
49
+ return output.join('\n') + '\n';
50
+ };
51
+ exports.renderCommandSummary = renderCommandSummary;
52
+ const renderEventPayload = (payload) => chalk_1.default.white(`${formatting_1.ICONS.SUCCESS} Event payload = ${payload}\n`);
53
+ exports.renderEventPayload = renderEventPayload;
54
+ const renderMissingPdbFile = (pdbFilename, dllPath) => chalk_1.default.yellow(`${formatting_1.ICONS.WARNING} Error: Missing '${pdbFilename}' file expected for ${dllPath}`);
55
+ exports.renderMissingPdbFile = renderMissingPdbFile;
56
+ const renderGitWarning = (errorMessage) => chalk_1.default.yellow(`${formatting_1.ICONS.WARNING} An error occured while invoking git: ${errorMessage}
57
+ Make sure the command is running within your git repository to fully leverage Datadog's git integration.
58
+ To ignore this warning use the --disable-git flag.\n`);
59
+ exports.renderGitWarning = renderGitWarning;
60
+ const renderWarning = (errorMessage) => chalk_1.default.yellow(`${formatting_1.ICONS.WARNING} ${errorMessage}.\n`);
61
+ exports.renderWarning = renderWarning;
62
+ const renderArgumentMissingError = (argumentName) => chalk_1.default.red(`${formatting_1.ICONS.FAILED} Error: parameter "${argumentName}" is required.\n`);
63
+ exports.renderArgumentMissingError = renderArgumentMissingError;
64
+ const renderInvalidSymbolsLocation = (symbolsDirectory) => chalk_1.default.red(`${formatting_1.ICONS.FAILED} Failed to get symbols files - ${symbolsDirectory} is not a file, nor a directory.\n`);
65
+ exports.renderInvalidSymbolsLocation = renderInvalidSymbolsLocation;
66
+ const renderGeneralizedError = (error) => {
67
+ let str = chalk_1.default.red(`${formatting_1.ICONS.FAILED} Error: ${error}\n`);
68
+ str += error.stack;
69
+ return str;
70
+ };
71
+ exports.renderGeneralizedError = renderGeneralizedError;
72
+ const renderFailedUpload = (filePath, errorMessage) => {
73
+ const filePathBold = `[${chalk_1.default.bold.dim(filePath)}]`;
74
+ return chalk_1.default.red(`${formatting_1.ICONS.FAILED} Failed upload for ${filePathBold}: ${errorMessage}\n`);
75
+ };
76
+ exports.renderFailedUpload = renderFailedUpload;
77
+ const renderRetriedUpload = (filePath, errorMessage, attempt) => {
78
+ const sourcemapPathBold = `[${chalk_1.default.bold.dim(filePath)}]`;
79
+ return chalk_1.default.yellow(`[attempt ${attempt}] Retrying upload ${sourcemapPathBold}: ${errorMessage}\n`);
80
+ };
81
+ exports.renderRetriedUpload = renderRetriedUpload;
82
+ const renderUpload = (filePath, metadata) => `Uploading debug info for ${filePath} (arch:${metadata.arch} \
83
+ pdb_age:${metadata.pdb_age} \
84
+ pdb_sig:${metadata.pdb_sig} \
85
+ filename:${metadata.filename})\n`;
86
+ exports.renderUpload = renderUpload;
87
+ //# sourceMappingURL=renderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderer.js","sourceRoot":"","sources":["../../../src/commands/pe-symbols/renderer.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAyB;AAEzB,yDAA8C;AAC9C,iDAAiD;AACjD,+CAA6C;AAUtC,MAAM,iBAAiB,GAAG,CAAC,MAAe,EAAE,gBAA0B,EAAE,EAAE;IAC/E,IAAI,UAAU,GAAG,EAAE,CAAA;IACnB,IAAI,MAAM,EAAE;QACV,UAAU,IAAI,eAAK,CAAC,MAAM,CAAC,GAAG,kBAAK,CAAC,OAAO,kDAAkD,CAAC,CAAA;KAC/F;IACD,MAAM,QAAQ,GAAG,eAAK,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAA;IAEnD,UAAU,IAAI,QAAQ,CAAA;IACtB,UAAU,IAAI,eAAK,CAAC,KAAK,CAAC,uCAAuC,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAEhG,UAAU,IAAI,eAAK,CAAC,KAAK,CACvB,yGAAyG,CAC1G,CAAA;IAED,OAAO,UAAU,CAAA;AACnB,CAAC,CAAA;AAfY,QAAA,iBAAiB,qBAe7B;AAEM,MAAM,oBAAoB,GAAG,CAAC,QAAwB,EAAE,QAAgB,EAAE,MAAe,EAAE,EAAE;IAClG,MAAM,OAAO,GAAG,IAAI,GAAG,EAAwB,CAAA;IAC/C,QAAQ,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;QAC1B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;YACxB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;SACvB;QACD,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CA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C,MAAM,WAAW,KAAK,IAAI,CAAC,CAAA;IACxD,GAAG,IAAI,KAAK,CAAC,KAAK,CAAA;IAElB,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AALY,QAAA,sBAAsB,0BAKlC;AAEM,MAAM,kBAAkB,GAAG,CAAC,QAAgB,EAAE,YAAoB,EAAE,EAAE;IAC3E,MAAM,YAAY,GAAG,IAAI,eAAK,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAA;IAEpD,OAAO,eAAK,CAAC,GAAG,CAAC,GAAG,kBAAK,CAAC,MAAM,sBAAsB,YAAY,KAAK,YAAY,IAAI,CAAC,CAAA;AAC1F,CAAC,CAAA;AAJY,QAAA,kBAAkB,sBAI9B;AAEM,MAAM,mBAAmB,GAAG,CAAC,QAAgB,EAAE,YAAoB,EAAE,OAAe,EAAE,EAAE;IAC7F,MAAM,iBAAiB,GAAG,IAAI,eAAK,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAA;IAEzD,OAAO,eAAK,CAAC,MAAM,CAAC,YAAY,OAAO,qBAAqB,iBAAiB,KAAK,YAAY,IAAI,CAAC,CAAA;AACrG,CAAC,CAAA;AAJY,QAAA,mBAAmB,uBAI/B;AAEM,MAAM,YAAY,GAAG,CAAC,QAAgB,EAAE,QAAyB,EAAU,EAAE,CAClF,4BAA4B,QAAQ,UAAU,QAAQ,CAAC,IAAI;UACnD,QAAQ,CAAC,OAAO;UAChB,QAAQ,CAAC,OAAO;WACf,QAAQ,CAAC,QAAQ,KAAK,CAAA;AAJpB,QAAA,YAAY,gBAIQ"}
@@ -0,0 +1,32 @@
1
+ import { Command } from 'clipanion';
2
+ export declare class UploadCommand extends Command {
3
+ static paths: string[][];
4
+ static usage: import("clipanion").Usage;
5
+ private disableGit;
6
+ private dryRun;
7
+ private configPath;
8
+ private maxConcurrency;
9
+ private repositoryUrl;
10
+ private replaceExisting;
11
+ private symbolsLocations;
12
+ private cliVersion;
13
+ private config;
14
+ private gitData?;
15
+ private fips;
16
+ private fipsIgnoreError;
17
+ private fipsConfig;
18
+ execute(): Promise<0 | 1>;
19
+ private getApiKeyValidator;
20
+ private getGitDataPayload;
21
+ private getGitMetadata;
22
+ private getPESymbolSource;
23
+ private getArchitecture;
24
+ private getMappingMetadata;
25
+ private getMetricsLogger;
26
+ private getPESymbolFiles;
27
+ private removeBuildIdDuplicates;
28
+ private getFileInSameFolder;
29
+ private getAssociatedPdbFilename;
30
+ private performPESymbolsUpload;
31
+ private verifyParameters;
32
+ }