问:我已经在Cordova Framework中开发了一个应用程序,并且添加了一个用于捕获功能的相机插件。
我在以下代码中发现信息泄漏漏洞,我认为我需要初始化,使用veracode扫描APK。我需要初始化OutputStream吗?
OutputStream os = this.cordova.getActivity().getContentResolver().openOutputStream(uri);
try {
bitmap.compress(Bitmap.CompressFormat.JPEG, this.mQuality, os);
os.close();
} finally {
if (os != null) {
os.close();
}
}
答:请比较CameraLauncher.java文件第535行的代码:
Uri uri = Uri.fromFile(createCaptureFile(this.encodingType,System.currentTimeMillis()+“”)));
位图= getScaledBitmap(sourcePath);
//仔细检查位图。
如果(位图==空){
Log.d(LOG_ TAG,“我的图像路径或位图为空”);
this.failPicture(“无法创建位图!”);
返回;
}
if(rotate!= 0 && this.correctOrientation){
位图= getRotatedBitmap(旋转,位图,exif);
}
//将捕获的图像的压缩版本添加到返回的媒体存储区Uri
OutputStream os = this.cordova.getActivity()。getContentResolver()。openOutputStream(uri);
CompressFormat compressFormat = encodingType == JPEG吗?
CompressFormat.JPEG:
CompressFormat.PNG;
bitmap.compress(compressFormat,this.mQuality,os);
os.close();
//将exif数据还原到文件
如果(this.encodingType == JPEG){
字符串exifPath;
exifPath = uri.getPath();
exif.createOutFile(exifPath);
exif.writeExifData();
}
//将Uri发送回JavaScript以查看图像
this.callbackContext.success(uri.toString());
另外,我正在使用cordova 6.1.0版本和相机插件正常工作。