Allow filesystem to decide path validity for cert dest folder (sonarCA.cert failing to write on windows)
Summary: On windows when I used a more complicated path for the sonar directory (e.g. for writing sonarCA.cert to), it failed this regex but succeeded the node fs.writeFile call. Unless I'm missing something else this regex does, we should just let the authority of the fs module decide if it can write something. Reviewed By: jknoxville Differential Revision: D8822094 fbshipit-source-id: 294c9a7b70080fefcfffdddd239d321ff7faa4e1
This commit is contained in:
committed by
Facebook Github Bot
parent
e844e4bd34
commit
d34aba9e21
@@ -33,7 +33,6 @@ const serverSubject = '/C=US/ST=CA/L=Menlo Park/O=Sonar/CN=localhost';
|
|||||||
const minCertExpiryWindowSeconds = 24 * 60 * 60;
|
const minCertExpiryWindowSeconds = 24 * 60 * 60;
|
||||||
const appNotDebuggableRegex = /debuggable/;
|
const appNotDebuggableRegex = /debuggable/;
|
||||||
const allowedAppNameRegex = /^[a-zA-Z0-9.\-]+$/;
|
const allowedAppNameRegex = /^[a-zA-Z0-9.\-]+$/;
|
||||||
const allowedAppDirectoryRegex = /^\/[ a-zA-Z0-9.\-\/]+$/;
|
|
||||||
const operationNotPermittedRegex = /not permitted/;
|
const operationNotPermittedRegex = /not permitted/;
|
||||||
const logTag = 'CertificateProvider';
|
const logTag = 'CertificateProvider';
|
||||||
/*
|
/*
|
||||||
@@ -81,13 +80,6 @@ export default class CertificateProvider {
|
|||||||
appDirectory: string,
|
appDirectory: string,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
this.ensureOpenSSLIsAvailable();
|
this.ensureOpenSSLIsAvailable();
|
||||||
if (!appDirectory.match(allowedAppDirectoryRegex)) {
|
|
||||||
return Promise.reject(
|
|
||||||
new RecurringError(
|
|
||||||
`Invalid appDirectory recieved from ${os} device: ${appDirectory}`,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return this.certificateSetup
|
return this.certificateSetup
|
||||||
.then(_ => this.getCACertificate())
|
.then(_ => this.getCACertificate())
|
||||||
.then(caCert =>
|
.then(caCert =>
|
||||||
@@ -172,8 +164,18 @@ export default class CertificateProvider {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (os === 'iOS' || os === 'windows') {
|
if (os === 'iOS' || os === 'windows') {
|
||||||
fs.writeFileSync(destination + filename, contents);
|
return new Promise((resolve, reject) => {
|
||||||
return Promise.resolve();
|
fs.writeFile(destination + filename, contents, err => {
|
||||||
|
if (err) {
|
||||||
|
reject(
|
||||||
|
`Invalid appDirectory recieved from ${os} device: ${destination}: ` +
|
||||||
|
err.toString(),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return Promise.reject(new RecurringError(`Unsupported device os: ${os}`));
|
return Promise.reject(new RecurringError(`Unsupported device os: ${os}`));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user