mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
fix secret and JavaScript compliance issues (#6408)
fix secret and JavaScript compliance issues - mark secrets as a test only secrets - make javascript use strict in a specific function
This commit is contained in:
@@ -1,56 +1,60 @@
|
||||
"use strict";
|
||||
var gulp = require("gulp");
|
||||
var concat = require("gulp-concat");
|
||||
var through2 = require("through2");
|
||||
var markdownlint = require("markdownlint");
|
||||
function RunTest() {
|
||||
"use strict";
|
||||
var gulp = require("gulp");
|
||||
var concat = require("gulp-concat");
|
||||
var through2 = require("through2");
|
||||
var markdownlint = require("markdownlint");
|
||||
|
||||
gulp.task("test-mdsyntax", function task() {
|
||||
var paths = [];
|
||||
var rootpath;
|
||||
gulp.task("test-mdsyntax", function task() {
|
||||
var paths = [];
|
||||
var rootpath;
|
||||
|
||||
// assign --repoRoot <rootpath> into rootpath
|
||||
var j = process.argv.indexOf("--rootpath");
|
||||
if (j > -1) {
|
||||
rootpath = process.argv[j + 1];
|
||||
}
|
||||
// assign --repoRoot <rootpath> into rootpath
|
||||
var j = process.argv.indexOf("--rootpath");
|
||||
if (j > -1) {
|
||||
rootpath = process.argv[j + 1];
|
||||
}
|
||||
|
||||
if(rootpath == null)
|
||||
{
|
||||
throw "--rootpath <repoRoot> must be specified before all other parameters"
|
||||
}
|
||||
if(rootpath == null)
|
||||
{
|
||||
throw "--rootpath <repoRoot> must be specified before all other parameters"
|
||||
}
|
||||
|
||||
// parse --filter into paths. --rootpath must be specified first.
|
||||
var j = process.argv.indexOf("--filter");
|
||||
if (j > -1) {
|
||||
var filters = process.argv[j + 1].split(",");
|
||||
filters.forEach(function (filter) {
|
||||
paths.push(rootpath + "/" + filter);
|
||||
}, this);
|
||||
}
|
||||
// parse --filter into paths. --rootpath must be specified first.
|
||||
var j = process.argv.indexOf("--filter");
|
||||
if (j > -1) {
|
||||
var filters = process.argv[j + 1].split(",");
|
||||
filters.forEach(function (filter) {
|
||||
paths.push(rootpath + "/" + filter);
|
||||
}, this);
|
||||
}
|
||||
|
||||
if(paths.length == 0)
|
||||
{
|
||||
throw "--filter <filter relative to repoRoot> must be specified"
|
||||
}
|
||||
if(paths.length == 0)
|
||||
{
|
||||
throw "--filter <filter relative to repoRoot> must be specified"
|
||||
}
|
||||
|
||||
var rootJsonFile = rootpath + "/.markdownlint.json"
|
||||
var fs = require('fs');
|
||||
fs.appendFileSync('markdownissues.txt', '--EMPTY--\r\n');
|
||||
gulp.src(paths, { "read": false })
|
||||
.pipe(through2.obj(function obj(file, enc, next) {
|
||||
markdownlint(
|
||||
{
|
||||
"files": [file.path],
|
||||
"config": require(rootJsonFile)
|
||||
},
|
||||
function callback(err, result) {
|
||||
var resultString = (result || "").toString();
|
||||
if (resultString) {
|
||||
file.contents = new Buffer(resultString);
|
||||
}
|
||||
next(err, file);
|
||||
});
|
||||
}))
|
||||
.pipe(concat("markdownissues.txt", { newLine: "\r\n" }))
|
||||
.pipe(gulp.dest("."));
|
||||
});
|
||||
var rootJsonFile = rootpath + "/.markdownlint.json"
|
||||
var fs = require('fs');
|
||||
fs.appendFileSync('markdownissues.txt', '--EMPTY--\r\n');
|
||||
gulp.src(paths, { "read": false })
|
||||
.pipe(through2.obj(function obj(file, enc, next) {
|
||||
markdownlint(
|
||||
{
|
||||
"files": [file.path],
|
||||
"config": require(rootJsonFile)
|
||||
},
|
||||
function callback(err, result) {
|
||||
var resultString = (result || "").toString();
|
||||
if (resultString) {
|
||||
file.contents = new Buffer(resultString);
|
||||
}
|
||||
next(err, file);
|
||||
});
|
||||
}))
|
||||
.pipe(concat("markdownissues.txt", { newLine: "\r\n" }))
|
||||
.pipe(gulp.dest("."));
|
||||
});
|
||||
}
|
||||
|
||||
RunTest();
|
||||
|
||||
@@ -28,12 +28,14 @@ Describe "CmsMessage cmdlets and Get-PfxCertificate basic tests" -Tags "CI" {
|
||||
}
|
||||
|
||||
It "Verify Get-PfxCertificate right password" {
|
||||
#[SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine", Justification="Test secret.")]
|
||||
$pass = ConvertTo-SecureString "password" -AsPlainText -Force
|
||||
$cert = Get-PfxCertificate $protectedCertLocation -Password $pass
|
||||
$cert.Subject | Should Be "CN=localhost"
|
||||
}
|
||||
|
||||
It "Verify Get-PfxCertificate wrong password" {
|
||||
#[SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine", Justification="Test secret.")]
|
||||
$pass = ConvertTo-SecureString "wrongpass" -AsPlainText -Force
|
||||
$e = { Get-PfxCertificate $protectedCertLocation -Password $pass -ErrorAction Stop } | ShouldBeErrorId "GetPfxCertificateUnknownCryptoError,Microsoft.PowerShell.Commands.GetPfxCertificateCommand"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user