test
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
mol
2024-07-06 22:23:31 +08:00
parent 08173d8497
commit 263cb5ef03
1663 changed files with 526884 additions and 0 deletions

View File

@ -0,0 +1,23 @@
vscode-deviceid
Copyright (c) Microsoft Corporation.
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,41 @@
<!-- BEGIN MICROSOFT SECURITY.MD V0.0.9 BLOCK -->
## Security
Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet) and [Xamarin](https://github.com/xamarin).
If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/security.md/definition), please report it to us as described below.
## Reporting Security Issues
**Please do not report security vulnerabilities through public GitHub issues.**
Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/security.md/msrc/create-report).
If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/security.md/msrc/pgp).
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc).
Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
* Full paths of source file(s) related to the manifestation of the issue
* The location of the affected source code (tag/branch/commit or direct URL)
* Any special configuration required to reproduce the issue
* Step-by-step instructions to reproduce the issue
* Proof-of-concept or exploit code (if possible)
* Impact of the issue, including how an attacker might exploit the issue
This information will help us triage your report more quickly.
If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/security.md/msrc/bounty) page for more details about our active programs.
## Preferred Languages
We prefer all communications to be in English.
## Policy
Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/security.md/cvd).
<!-- END MICROSOFT SECURITY.MD BLOCK -->

View File

@ -0,0 +1,106 @@
name: $(Date:yyyyMMdd)$(Rev:.r)
trigger: # cause a pipeline to run whenever you push an update to the specified branches
batch: true
branches:
include:
- main
parameters:
- name: Publish
displayName: Push to public npm feed?
type: boolean
default: false
variables:
TeamName: 'Visual Studio Technical Insights'
# The `resources` specify the location and version of the 1ES PT.
resources:
repositories:
- repository: MicrobuildTemplate
type: git
name: 1ESPipelineTemplates/MicroBuildTemplate
ref: refs/heads/release
extends:
# The pipeline extends the 1ES PT which will inject different SDL and compliance tasks.
# For non-production pipelines, use "Unofficial" as defined below.
# For productions pipelines, use "Official".
template: /azure-pipelines/MicroBuild.1ES.Official.Publish.yml@MicroBuildTemplate
parameters:
customBuildTags:
- Ignore-Tag
pool:
name: VSEngSS-MicroBuild2022-1ES
os: windows # OS of the image. Allowed values: windows, linux, macOS
stages:
- stage: BuildAndPublishNpmPackage
jobs:
- job: BuildAndPublish
templateContext:
mb:
signing:
enabled: true
signType: Test
zipSources: false
displayName: Build and publish npm package
steps:
- task: NodeTool@0
inputs:
versionSpec: '17.x'
displayName: 'Install Node.js'
# lock to older version of python. We need diskutils which was removed in Python 3.12
- task: UsePythonVersion@0
inputs:
versionSpec: '3.11'
- script: |
npm ci
displayName: 'Install dependencies'
- script: |
npm run build
displayName: 'Compile npm package'
# Commenting out until we have tests
# - script: |
# npm run test
# displayName: 'Test npm package'
- powershell: |
New-Item -ItemType Directory -Path "$(Build.ArtifactStagingDirectory)\npmpackages" -Force
displayName: Create npm package directory
- script: |
npm pack --pack-destination "$(Build.ArtifactStagingDirectory)\npmpackages"
displayName: 'Create npm package'
- powershell: |
Get-ChildItem -Path "$(Build.ArtifactStagingDirectory)\npmpackages"
displayName: Get contents of $(Build.ArtifactStagingDirectory)\npmpackages
- ${{ if parameters.Publish }}:
- template: /azure-pipelines/MicroBuild.Publish.yml@MicroBuildTemplate
parameters:
intent: 'PackageDistribution'
contentType: 'npm'
contentSource: 'Folder'
folderLocation: '$(Build.ArtifactStagingDirectory)\npmpackages'
waitForReleaseCompletion: true
owners: 'piel@microsoft.com'
approvers: 'rdawson@microsoft.com'
- task: 1ES.PublishPipelineArtifact@1
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)'
artifactName: output
- task: TSAUpload@2
inputs:
GdnPublishTsaOnboard: true
GdnPublishTsaConfigFile: '$(Build.SourcesDirectory)/.config/TSAOptions.json'
displayName: 'TSA upload to Codebase (vscode-deviceid)'

Binary file not shown.

View File

@ -0,0 +1,50 @@
"use strict";
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See LICENSE in the project root for license information.
*--------------------------------------------------------------------------------------------*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDeviceId = void 0;
const uuid_1 = require("uuid");
const storage = __importStar(require("./storage.js"));
async function getDeviceId() {
let deviceId;
try {
deviceId = await storage.getDeviceId();
}
catch (e) {
// Regenerate the deviceId if it cannot be read
}
if (deviceId) {
return deviceId;
}
else {
const newDeviceId = (0, uuid_1.v4)().toLowerCase();
await storage.setDeviceId(newDeviceId);
return newDeviceId;
}
}
exports.getDeviceId = getDeviceId;

View File

@ -0,0 +1,26 @@
"use strict";
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See LICENSE in the project root for license information.
*--------------------------------------------------------------------------------------------*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
if (process.platform !== "win32" &&
process.platform !== "darwin" &&
process.platform !== "linux") {
throw new Error("Unsupported platform");
}
__exportStar(require("./devdeviceid.js"), exports);

View File

@ -0,0 +1,80 @@
"use strict";
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See LICENSE in the project root for license information.
*--------------------------------------------------------------------------------------------*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.setDeviceId = exports.getDeviceId = void 0;
const path = __importStar(require("path"));
const fs = __importStar(require("fs-extra"));
const windowRegistry = process.platform === "win32"
? require("../build/Release/windows.node")
: null;
const deviceIdFileName = "deviceid";
function getDirectory() {
let folder;
if (!process.env.HOME) {
throw new Error("Home directory not found");
}
if (process.platform === "darwin") {
folder = path.join(process.env.HOME, "Library", "Application Support");
}
else if (process.platform === "linux") {
folder =
process.env.XDG_CACHE_HOME ?? path.join(process.env.HOME, ".cache");
}
else {
throw new Error("Unsupported platform");
}
return path.join(folder, "Microsoft", "DeveloperTools");
}
function getDeviceIdFilePath() {
return path.join(getDirectory(), deviceIdFileName);
}
async function getDeviceId() {
if (process.platform === "win32") {
return windowRegistry?.GetDeviceId();
}
else {
if (!fs.existsSync(getDeviceIdFilePath())) {
return undefined;
}
else {
return fs.readFile(getDeviceIdFilePath(), "utf8");
}
}
}
exports.getDeviceId = getDeviceId;
async function setDeviceId(deviceId) {
if (process.platform === "win32") {
windowRegistry?.SetDeviceId(deviceId);
}
else {
await fs.ensureDir(getDirectory());
await fs.writeFile(getDeviceIdFilePath(), deviceId, "utf8");
}
}
exports.setDeviceId = setDeviceId;

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<!-- Please verify that the feed below exists for your project and replace placeholder values. You may also use another feed of your choice. -->
<add key="PublicPackages" value="https://pkgs.dev.azure.com/devdiv/DevDiv/_packaging/DevDiv_PublicPackages/nuget/v3/index.json" />
</packageSources>
</configuration>

View File

@ -0,0 +1,10 @@
; This owners.txt file was initially populated by StartRight. Every code
; change inside of an Ownership Enforcer enabled branch (such as master) must be
; approved by at least one expert listed in an applicable owners.txt file. This
; root owners.txt file is applicable to every change. Targeted experts can be
; defined by placing an owners.txt file inside any subdirectory. More information
; about Ownership Enforcer can be found at https://aka.ms/ownershipenforcer.
rdawson
riteshp
piel
jonathanyi

View File

@ -0,0 +1,29 @@
{
"name": "@vscode/deviceid",
"version": "0.1.1",
"description": "A module for Visual Studio Code to generate a unique device ID",
"main": "./dist/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "npm run compile",
"compile": "tsc",
"lint": "eslint . --max-warnings 0 --report-unused-disable-directives",
"lint:fix": "npm run lint -- --fix"
},
"keywords": [],
"author": "Microsoft Corporation",
"license": "MIT",
"devDependencies": {
"@types/fs-extra": "^11.0.4",
"@types/node": "^20.12.4",
"@types/uuid": "^9.0.8",
"@typescript-eslint/eslint-plugin": "^7.5.0",
"@typescript-eslint/parser": "^7.5.0",
"eslint": "^8.57.0",
"prettier": "^3.2.5"
},
"dependencies": {
"fs-extra": "^11.2.0",
"uuid": "^9.0.1"
}
}