Skip to content

Commit

Permalink
Update package version, change the sinsative value PASSWORD to PASS, …
Browse files Browse the repository at this point in the history
…add devcontainer configuration (#5)
  • Loading branch information
LTomer authored Mar 31, 2024
1 parent 8f37d8e commit 651ca2c
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 72 deletions.
22 changes: 22 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node
{
"name": "Node.js & TypeScript",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/typescript-node:1-20-bullseye"

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "yarn install",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Environment-Variables - Version 1.*
# Environment-Variables - Version 0.1.*

The purpose of this task is to print the environment variable to the build console.
If there is an error during the build process, it will print the environment variable on post-job, but if the checkbox "Print on Post job" selected it will print the details each time.

## New on version 1.1.*
## New on version 0.2.*

The task will hide the value in case the variable name includes one of the words in the list:
* PASSWORD
* PASS
* TOKEN
* SECRET

Expand Down
80 changes: 43 additions & 37 deletions Task/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Task/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
},
"homepage": "https://github.com/LTomer/vsts-environment-variables/blob/master/README.md",
"dependencies": {
"azure-pipelines-task-lib": "^4.6.0"
"azure-pipelines-task-lib": "^4.10.1"
},
"devDependencies": {
"@types/node": "^20.6.2",
"@types/q": "^1.5.6"
"@types/node": "^20.12.2",
"@types/q": "^1.5.8"
}
}
21 changes: 10 additions & 11 deletions Task/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,27 @@
"Build",
"Release"
],
"demands": [
],
"demands": [],
"version": {
"Major": "0",
"Minor": "2",
"Patch": "1"
"Patch": "4"
},
"minimumAgentVersion": "2.144.0",
"instanceNameFormat": "Environment Variables",
"inputs": [
{
"name": "PostJob",
"type": "boolean",
"label": "Print on Post-job",
"helpMarkDown": "Set to print Environment Variables every time, otherwise, print on error."
"name": "PostJob",
"type": "boolean",
"label": "Print on Post-job",
"helpMarkDown": "Set to print Environment Variables every time, otherwise, print on error."
},
{
"name": "ShowSensativeValue",
"type": "boolean",
"label": "Show Sensative Value",
"helpMarkDown": "If a variable name indicate that it contains sensative data and is not set as Azure DevOps Secret the value will print to the console - not recommended."
}
"helpMarkDown": "If a variable name indicate that it contains sensative data and is not set as Azure DevOps Secret the value will print to the console - NOT RECOMMENDED."
}
],
"execution": {
"Node10": {
Expand All @@ -40,8 +39,8 @@
},
"postjobexecution": {
"Node10": {
"target": "envPost.js",
"argumentFormat": ""
"target": "envPost.js",
"argumentFormat": ""
}
}
}
16 changes: 7 additions & 9 deletions Task/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,26 @@ import * as taskLib from 'azure-pipelines-task-lib/task';
export function PrintVariable(): void {
const flag: boolean = taskLib.getBoolInput('ShowSensativeValue');
if (flag)
taskLib.warning("If an environment variable name contains 'PASSWORD', 'TOKEN', or 'SECRET' and is not set as a secret, the value will be printed to the console. This practice is not recommended for security reasons.")
taskLib.warning("If an environment variable name contains 'PASS', 'TOKEN', or 'SECRET' and is not set as a secret, the value will be printed to the console. This practice is not recommended for security reasons.")

let maxSize=0;
let maxSize = 0;
var jsObj = process.env
for(var key in jsObj)
{
for (var key in jsObj) {
maxSize = Math.max(maxSize, key.length)
}

var maxSpace = maxSize + 3;

let sortArray = Object.keys(jsObj).sort((a, b) => a.localeCompare(b))
for(var i in sortArray)
{
for (var i in sortArray) {
let currentKey = sortArray[i]
var spaces = Array(maxSpace - currentKey.length).join('.')

const tmpVarName = currentKey.toUpperCase()
let value = jsObj[currentKey]
if ( !flag && tmpVarName != "VSTS_SECRET_VARIABLES" && (tmpVarName.includes("TOKEN") || tmpVarName.includes("PASSWORD") || tmpVarName.includes("SECRET")))
if (!flag && tmpVarName != "VSTS_SECRET_VARIABLES" && (tmpVarName.includes("TOKEN") || tmpVarName.includes("PASS") || tmpVarName.includes("SECRET")))
value = "(***)"

console.log(`- ${currentKey} ${spaces} ${value}`)
}
}
8 changes: 4 additions & 4 deletions overview.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Environment-Variables - Version 1.*
# Environment-Variables - Version 0.1.*

This task print the environment variable to the Azure DevOps pipeline console.
If the process is not successfully completed, it will print the environment variable at the post-process.

## New on version 1.1.*
## New on version 0.2.*
The task will hide the value in case the variable name includes one of the words in the list:
* PASSWORD
* PASS
* TOKEN
* SECRET

For example, The value of the variable name called 'UserPassword' will pring '(***)' instead of the value itself.
For example, The value of the variable name called 'UserPassword' will print '(***)' instead of the value itself.
> For debug mode you can set the flag 'ShowSensativeValue' to true and it will print the value in case it is not an Azure DevOps secret variable (Warning message will print) - ___Not recommended___
_For more information, read the documents in the GIT repo._
11 changes: 6 additions & 5 deletions vss-extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"manifestVersion": 1,
"id": "environment-variables",
"name": "Environment Variables",
"version": "0.0.13",
"version": "0.0.16",
"publisher": "Tomer",
"targets": [
{
"id": "Microsoft.VisualStudio.Services"
}
],
],
"description": "Show Environment Variables.",
"galleryFlags": [
"Public"
Expand All @@ -17,15 +17,16 @@
"Azure Pipelines"
],
"icons": {
"default": "images/icon-128.png"
"default": "images/icon-128.png"
},
"files": [
{
"path": "Task"
}
],
"tags": [
"Environment Variables", "Variable"
"Environment Variables",
"Variable"
],
"content": {
"details": {
Expand All @@ -49,4 +50,4 @@
}
}
]
}
}

0 comments on commit 651ca2c

Please sign in to comment.