Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
mssql-ssrs
Advanced tools
Promise based api for MSSQL Reporting Services with ntlm and basic security
Promise based api for MSSQL reporting services
Install with npm:
npm install mssql-ssrs
MSSQL has 2 parts for reporting services:
To start using reporting services we need to connect to the server first:
start both services (reportService, reportExecution)
var { ReportManager } = require('mssql-ssrs');
var ssrs = new ReportManager([cacheReports]);
await ssrs.start(url/path/serverConfig, soapConfig [, options] [, security]);
const list = await ssrs.reportService.listChildren(reportPath);
const report = await ssrs.reportExecution.getReport(reportPath, fileType, parameters);
...
or start them separately
var { ReportService, ReportExecution } = require('mssql-ssrs');
var rs = new ReportService();
await rs.start(url/Path/serverConfig, soapConfig [, options] [, security]);
var re = new ReportExecution();
await re.start(url/Path/serverConfig, soapConfig [, options] [, security]);
NOTE: Report Execution via Url does not have or require start
The url/serverConfig/path
argument accepts a string url, config object or a system file path (the file path option must contain a valid ssrs wsdl file from reporting services):
var url = 'http(s)://<serverName>:<port>/ReportServer_<sqlInstance>',
var serverConfig = {
server: 'serverName',
instance: 'serverInstance',
isHttps: false, // optional, default: false
port: 80, // optional, default: 80
};
soapConfig, can include directly on config object or on config.wsdl_options the folowing properties for ssrs connection:
username
: '', (required)password
: '', (required)workstation
: '', (optional)domain
: '', (optional)rootFolder
: base folder added to reportPath
parameters, default: '/'useRs2012
: specify witch version of wsdl should client use (2010/2012), default: false (2010)cache
: specify whether to cache report list, default false
cacheOnStart
: specify whether to cache all reports when starting report services, default falsecacheReports
can also be set directly when instatiating ReportManager
cache
option on start
cacheOnStart
option is stil needed if all reports should be cached at start
More information on types of security see soap security
Defaults to NTLM security so no extra steps needed, just start
// ex:
await ssrs.start(url, { username: username, password: password });
// start everything
await ssrs.start(url/Path/serverConfig, soapConfig [, options] [, security]);
// or start separately
var rs = new ReportService();
await rs.start(url/Path/serverConfig, soapConfig [, options] [, security]);
var re = new ReportExecution();
await re.start(url/Path/serverConfig, soapConfig [, options] [, security]);
// added in the same way for any other security type you use
// instanciating security type can differ
var auth = { username: username, password: password };
await ssrs.start(url, auth, null, 'basic');
// or
var wsdl_headers = {};
var security = new ssrs.soap.security.BasicAuthSecurity(auth.username, auth.password);
security.addHeaders(wsdl_headers); // add authorization
await ssrs.start(url, { wsdl_headers: wsdl_headers }, null, security);
var { ReportService } = require('mssql-ssrs');
var reportService = new ReportService();
await reportService.start(url/Path/serverConfig, soapConfig [, options] [, security]);
var client = reportService.getClient();
or
reportService.client['functionName']()
var description = reportService.getDescription();
List all children down from current specified folder, if recursive is used it will go down into all folders
var reportList = await reportService.listChildren(reportPath[, isRcursive]);
var params = await reportService.getReportParams(reportPath[, forRendering]);
var params = await reportService.updateReportParams(reportPath, params[, formatParams]);
For all DataSourceDefinition properties use microsoft documentation
var status = await reportService.testDataSourceConnection(userName, password, dataSourceDefinition)
Example for dataSourceDefinition
:
DataSourceDefinition: {
Extension: 'SQL',
ConnectString: 'Data Source=<server>\\<instance>;Initial Catalog=<DbName>'
}
If properties are given, all report properties are returned. Report custom properties are not available
var properties = ['Hidden', 'Description'];
// or
var properties = [{ Name: 'Hidden' }, { Name: 'Description' }];
var properties = await reportService.getProperties(reportPath[, properties])
var properties = { Hidden: true, Description: 'my description' };
// or
var properties = [
{ Name: 'Hidden', Value: true },
{ Name: 'Description', Value: 'my description' }
];
var properties = await reportService.setProperties(reportPath, properties)
var jobs = await reportService.listJobs()
await reportService.cancelJob(jobId)
var rdl = await reportService.getItemDefinition(reportPath)
await reportService.createFolder(folderName, path)
var dataSource = await reportService.createDataSource(dataSourceName, folderPath, overwrite, definition, description, isHidden)
dataSourceName
: The name for the data source including the file name and, in SharePoint mode, the extension (.rsds).folderPath
: The fully qualified URL for the parent folder that will contain the data source.overwrite
: default false, indicates whether an existing data source with the same name in the location specified should be overwritten.definition
: A DataSourceDefinition
object that describes the connection properties for the data source.description
: report descriptionisHidden
: hide report in ssrsConnectString
: 'data source=server\instance; initial catalog=databaseName'UseOriginalConnectString
: data source should revert to the original connection stringOriginalConnectStringExpressionBased
: indicates whether the original connection string for the data source was expression-based.Extension
: SQL, OLEDB, ODBC, or a customEnabled
: enable/disable datasourceEnabledSpecified
: true if the Enabled
property should be omitted from the Web service call; otherwise, false. The default is false.CredentialRetrieval
: Prompt, Store, Integrated, NoneWindowsCredentials
: indicates whether the report server passes user-provided or stored credentials as Windows credentials when it connects to a data source.ImpersonateUser
: indicates whether the report server tries to impersonate a user by using stored credentials.ImpersonateUserSpecified
: true if the ImpersonateUser
property should be omitted from the Web service call; otherwise, false. The default is false.Prompt
: prompt that the report server displays to the user when it prompts for credentials.UserName
: authPassword
: authMostly as above but definition
property is a ReportDefinition
object
var report = await reportService.createReport(reportName, folderPath, overwrite, definition, description, isHidden)
- `reportName`: report name
- `folderPath`: report folder destination
- `overwrite`: overwrite if already exists
- `definition`: report definition xml string (will be automaticaly converted to base64)
- `description`: report description
- `isHidden`: report manager property hidden
await reportService.deleteItem(path)
Usually used for creating images
var resurce = await reportService.createResource(name, path, fileContents, overwrite, mimeType);
var references = await reportService.getItemDataSources(itemPath);
var dataSources = { dataSourceName: 'dataSourcesNewReferencePath' });
var references = await reportService.setItemDataSources(itemPath, dataSources);
itemPath
: path of the report including the file namedataSources
: object of dataSourceName: newValue type.var references = await reportService.getItemReferences(itemPath, referenceType);
itemPath
: path of the report including the file namereferenceType
: 'DataSource'|'DataSet'...var refs = { 'DataSourceName': '/path/DataSourceName' };
var refs = [{ Name: 'DataSourceName': Reference: '/path/DataSourceName' }];
var references = await reportService.setItemReferences(itemPath, refs);
itemPath
: path of the report including the file namerefs
: array of objects with name and reference pathsvar { ReportExecution } = require('mssql-ssrs');
var reportExecution = new ReportExecution();
await reportExecution.start(url/Path/serverConfig, soapConfig [, options] [, security]);
Using client soap directly
var client = reportExecution.getClient();
or
reportExecution.client['functionName']()
var description = reportExecution.getDescription()
var extensions = await reportExecution.listRenderingExtensions()
var reportPath = '/Folder/ReportName';
var fileType = 'pdf';
var parameters = {
parameterName1: 1,
parameterName2: false,
parameterName3: 'parameterValue',
multiValue: ['value1', 'value2']
};
//or
var parameters = [
{ Name: 'parameterName1', Value: 1 },
{ Name: 'parameterName2', Value: false },
{ Name: 'parameterName3', Value: 'parameterValue' },
{ Name: 'multiValue', Value: ['value1', 'value2'] }
]
var report = await reportExecution.getReport(reportPath, fileType, parameters)
parameters
can be an object with name, value atributes or instance of ReportParameterInfo
objects
NOTE: HTML render will automatically get associated image streams from the report server in base64 inside the htmlreport result:
{
"Extension": "pdf",
"MimeType": "application/pdf",
"Result:" "", // base64 string, this is the pdf
"StreamIds": null
}
No need to use start
function (it does not exist)
var { ReportExecutionUrl } = require('mssql-ssrs');
var auth = {
username: 'userName',
password: 'password',
workstation: '', // optional
domain: '' // optional
};
var re = new ReportExecutionUrl(url/path/serverConfig, auth[, options][, axiosConfig]);
options
: optional
var report = await re.getReport(reportPath, fileType, parameters, axiosConfig)
reportPath
: path to the reportfileType
: the report file tipe of file extensionparameters
can be an object with { name: value } properties or instance of ReportParameterInfo
objectsaxiosConfig
: local axios config for overriding defaults per requestreturned result is an axios response schema
{
data: Buffer,
status: ...,
statusText: ...,
headers: ...,
config: ...,
request: ...
}
var { ReportManager } = require('mssql-ssrs');
var ssrs = new ReportManager();
await ssrs.start(url/Path/serverConfig, soapConfig [, options] [, security]);
var references = await ssrs.fixDataSourceReference(reportPath, dataSourcePath[, logger]);
reportPath
: path to reports
dataSourcePath
: path to data source
log
: boolean, outputs to console
or
log
: object
log
: function for normal log messageswarn
: function for log warrning/error messagesGet report list from cache, if path is not found in cache it will be download and cached
var reportList = await ssrs.getReportList(reportPath [, forceRefresh])
reportPath
is not present of is the same as rootFolder for reports entire cache is returnedforceRefresh
force a recache, if reportPath
is not present rootFolder
is usedawait ssrs.cacheReportList(reportPath[, keepHidden])
await ssrs.clearCache()
Report Builder only installs from ie/edge
var link = await ssrs.reportBuilder(reportPath)
Create a copy of a specified report in the same folder and return new report
var newReport = await ssrs.createReportCopy(reportPath, options)
Inspired from Report Loader
Download list of all items down from specified path, can also be used for 1 specific report
var fileList = await ssrs.download(reportPath)
reportPath
: string|Array of strings path for base folders in report service from where to create definitions.var result = await ssrs.readFiles(filePath, exclude, noDefinitions);
filePath
: path to folder to readexclude
: array of strings to exclude specified files paths, names or extensionsnoDefinitions
: does not read file content(definition)Upload items (report/datasource/image) or entire folder structure to reporting services
var warrnings = await ssrs.upload(filePath, reportPath, options)
filePath
: root folder path where to read filesreportPath
: report path where to upload filesoptions
for upload
and uploadFiles
are the sameRead file directory and upload reports
var warrnings = await ssrs.uploadFiles(filePath [, reportPath] [, options]);
var warrnings = await ssrs.uploadFiles('.path/to/root/directory', '/newReportFolderName', {
overwrite: false,
keepDataSource: true, // keep existing datasources
deleteExistingItems: false,
fixDataSourceReference: false,
exclude: ['folderName', '.extension', '/path/to/file.rdl'],
include: { folders: [], dataSources: [], reports: [] },
dataSourceOptions: {
myDataSourceName: {
ConnectString: 'data source=<server>\<instance>; initial catalog=<dbName>',
UserName: '',
Password: ''
},
mySecondDataSourceName: {
WindowsCredentials: true,
ConnectString: 'data source=<server>\<instance>; initial catalog=<dbName>',
UserName: '',
Password: ''
}
},
logger: true || {
log: function (msg) { console.log(msg) },
warn: function (msg) { console.warn(msg) }
}
}});
filePath
: root folder from where to read filesreportPath
: report path where to upload, if not specified last folder name from filePath
is usedoptions
: additional properties object, optional
exclude
: array of strings to exclude specified files paths, names or extensionsoverwrite
: overrites reports and datasources on upload, default truedeleteExistingItems
: delete items before upload, default falsekeepDataSource
: do not delete existing datasources, default falsefixDataSourceReference
: fix uploaded reports datasource references with uploaded datasources, default truedataSourceOptions
: each dataSourceName and its connection properties
dataSourceName
:
connectstring
: connection string for data sourceuserName
: userName for data sourcepassword
: password for data sourcelogger
: boolean, outputs to consolelogger
: object
log
: log messages functionwarn
: log warrning/error messages functionCreates soap clients (used for creating reportService and reportExecution client)
types of soap security
const ssrs = require('mssql-ssrs')
var customSecurity = await ssrs.soap.security.BasicAuthSecurity('username', 'password');
var customSecurity = await ssrs.soap.security.NTLMSecurity('username', 'password', 'domain', 'workstation');
var customSecurity = await ssrs.soap.security.NTLMSecurity({
username: username,
password: password,
domain: domain,
workstation: workstation
});
const { soap, SsrsSoap } = require('mssql-ssrs')
const ssrs = new SsrsSoap([url][, options])
const client = await ssrs.createClient(url, config[, security])
url
: url/serverConfig/pathconfig
: { username:'', password:'', domain: '', workstation: '', ...otherOptions }security
: 'ntlm' | 'basic' | customSecurityFAQs
Promise based api for MSSQL Reporting Services with ntlm and basic security
The npm package mssql-ssrs receives a total of 223 weekly downloads. As such, mssql-ssrs popularity was classified as not popular.
We found that mssql-ssrs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.