Anonymous_User Absent Member.
Absent Member.
479 views

Parsing failed: TypeError: Cannot find function save. input:


Hi

Currently i'm trying to create some Collector (McAfee Vul) using
Database connector(MS SQL Server).
Sentinel 7 with jtds-1.3.1.jar JDBC driver

Connection seems ok as show below:
[image:
https://fbcdn-sphotos-c-a.akamaihd.net/hphotos-ak-prn1/t1.0-9/10157241_10152402990359776_868086013446908924_n.jpg]

But returned following error in the search:
Message: Parsing failed: TypeError: Cannot find function save.; input:
undefined

The query should be ok (Have some records although is last year
records).

I'm still unsure what is resulting that error. Any idea?

Below are the codes


Code:
--------------------
Collector.prototype.initialize = function(){
this.MAPS.sevMap = new KeyMap(this.CONFIG.collDir + "severity.map");
this.MAPS.protocolMap = new KeyMap(this.CONFIG.collDir + "protocols.map");

this.PARSER.getOffsetData = function(input) {
if (typeof input.RXMap != "undefined") {
return input.RXMap.vulnName;
}
conn.addParser(this.PARSER.getOffsetData);
}
return true;
};

Collector.prototype.cleanup = function(){
return true;
};

Connector.prototype.sendQuery = function() {
return true;
}

Record.prototype.preParse = function(e){
if (this.CONNECTION_ERROR != null || typeof this.RXMap == "undefined") { return false; }
if (this.CONNECTION_METHOD == "DATABASE"){
for (var field in this.RXMap) {
this[field] = this.RXMap[field];
}
}
return true;
};

Record.prototype.parse = function(e){
//var dt = new Date();
//e.setDeviceEventTime(dt);
this.EventName = "TEST";
return true;
};

Record.prototype.normalize = function(e){
instance.SEND_EVENT = true;
return true;
};

Record.prototype.postParse = function(e){
return true;
};

Record.prototype.reply = function(e) {
return true;
}
--------------------



Code:
--------------------
SELECT * FROM
( SELECT Top %d (row_number() over (ORDER BY Hosts.IPAddress)) as rowIndex,
VulnsTemp.Name vulnName,
VulnsTemp.Risk severity,
VulnsTemp.Description summary,
VulnsTemp.Observation description,
VulnsTemp.Recommendation solution,
VulnsTemp.CVE CVE,
VulnsTemp.BID BID,
VulnsTemp.MSFTID MSFTID,
Jobs.StartTime startTime,
Jobs.EndTime stopTime,
Hosts.OSName OS,
Hosts.IPAddress IP,
Hosts.NBName hostName,
Hosts.MACAddress macAddress,
VulnsFound.FaultlineID ModuleID,
Services.Port port,
Services.Protocol protocol
FROM VulnsTemp inner join VulnsFound on VulnsTemp.FaultlineID = VulnsFound.FaultlineID
left join Jobs on VulnsFound.JobID = Jobs.JobID
left join Hosts on VulnsFound.HostID = Hosts.HostID
left join ServicesFound on VulnsFound.HostID = ServicesFound.HostID
left join Services on ServicesFound.ServiceID = Services.ServiceID
WHERE VulnsTemp.FaultlineID = VulnsFound.FaultlineID AND
Jobs.JobID = VulnsFound.JobID AND
Hosts.HostID = VulnsFound.HostID AND
ServicesFound.HostID = Hosts.HostID AND
ServicesFound.ServiceID = Services.ServiceID AND
Jobs.State = 'Complete' AND
VulnsFound.VulnFoundID > %s
) as temp
WHERE temp.rowIndex > 0
--------------------


--
mokie
------------------------------------------------------------------------
mokie's Profile: https://forums.netiq.com/member.php?userid=6189
View this thread: https://forums.netiq.com/showthread.php?t=50701

0 Likes
5 Replies
Anonymous_User Absent Member.
Absent Member.

Re: Parsing failed: TypeError: Cannot find function save. input:

Have you tried using the debugger to step through to find the error's
line? It would help to know what is happening up until the error is
thrown and the debugger is used for that kind of things..

--
Good luck.

If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below...
0 Likes
Anonymous_User Absent Member.
Absent Member.

Re: Parsing failed: TypeError: Cannot find function save. input:


One thing I notice is that you use VulnsFound.VulnFoundID as offset in
your query but you use input.RXMap.vulnName in your code.
This should of course be the same one, I even suspect you should use:
VulnsFound.VulnFoundID VulnfoundID, in your select and use
input.RXMap.col_VulnFoundID in your code.

It probably tries to find input.RXMap.vulnName in your input and fails
with the error you describe because it can't find the field. You can
check this in the debugger.

Hope this helps,
Anco


--
jcvader1
------------------------------------------------------------------------
jcvader1's Profile: https://forums.netiq.com/member.php?userid=502
View this thread: https://forums.netiq.com/showthread.php?t=50701

0 Likes
Anonymous_User Absent Member.
Absent Member.

Re: Parsing failed: TypeError: Cannot find function save. input:


For the col_ , that one already check, I didnt map it into col_ in the
connectionMethods.xml


Currently after debuging always keep stuck in (connector.js) ...


Code:
--------------------

switch(record.Row_Left) {
case "-2":
instance.QUERIES[record.s_RV24].setOffset(record.connectorData.offset);
// This handles a case where multiple -2 records are sitting in the Connector queue and have to be consumed before
// we get to the results from our query
if (instance.QUERIES[record.s_RV24].queryDelay > -1) {
conn.send(instance.QUERIES[record.s_RV24]);
instance.QUERIES[record.s_RV24].queryDelay = -1;
}
// Send the initial query to the DB
record.CONNECTION_ERROR = "OFFSET_NOT_EVENT";
return record;

--------------------


It never goes to other than that, Im not sure what is the problem.
Any idea?


--
mokie
------------------------------------------------------------------------
mokie's Profile: https://forums.netiq.com/member.php?userid=6189
View this thread: https://forums.netiq.com/showthread.php?t=50701

0 Likes
Anonymous_User Absent Member.
Absent Member.

Re: Parsing failed: TypeError: Cannot find function save. input:


The Row_Left=-2 is send by the collector to signal the offset which it
starts from and which will be set in the %s in the next query.
Because this was incorrect set before, it could be that the value is not
valid now.
Go to the event source in esm, right click and select edit. Go to the
'Start Behavior and Offset' tab.
While you are testing I would put it to 'Always start from beginning of
data'.
This way when you start or restart the event source it will start from
the beginning of your table making sure you got always data to test.

Hope this helps,
Anco


--
jcvader1
------------------------------------------------------------------------
jcvader1's Profile: https://forums.netiq.com/member.php?userid=502
View this thread: https://forums.netiq.com/showthread.php?t=50701

0 Likes
Anonymous_User Absent Member.
Absent Member.

Re: Parsing failed: TypeError: Cannot find function save. input:


Two questions:

1) Is there a particular reason you are not using our existing McAfee
Vulnerability Manager Collector? Are you seeing issues with it working
with more recent versions of the product? If so, I highly recommend that
you file a bug on it so we can take a look.

2) Can I assume that the SQL you quote above is located in the
sqlquery.base file?

Generally speaking what's supposed to happen is that the Collector loads
the "template" SQL query from sqlquery.base (including the %s and %d
variables), then it goes and reads the first record from the Connector.
If you've just started the Connector (or Event Source), the very first
record you see should be a special '-2' record whose sole purpose is to
tell you where you left off (the last index read) last time you ran the
Collector. If you've *never* used that Event Source before, then the
Connector will use the default value from the connectionMethods.xml file
- which MUST work if you simply copy-paste into the SQL Query.

So anyway, the Collector will pick the offset out of the -2 record, use
it to replace the '%s' in the query above, and then issue that SQL Query
against the database. You should be able to step through in the debugger
and see exactly the query it's attempting to issue, or you can construct
it by looking at the -2 record and seeing what offset the Collector is
getting. Again, you should be able to copy/paste that query into any sql
query tool and have it work.

W.r.t the 'Cannot find function save' what that usually means is that
JavaScript is trying to call a function that's not present. Usually this
happens because you've made an assumption about a data type that is not
valid, at least in some circumstance. So for example if you're trying to
call String.toUpper, and you assume you're calling this on a string in
variable 'myvar', then myvar.toUpper() should work. But if you read some
data from the Connector and it comes back as a null, then 'myvar' won't
be a string and when you try to call myvar.toUpper(), you'll get that
error (because myvar isn't a String but maybe undefined or null, hence
there's no such thing as a toUpper() member function).

Clear as mud? 😉


--
DCorlette
------------------------------------------------------------------------
DCorlette's Profile: https://forums.netiq.com/member.php?userid=323
View this thread: https://forums.netiq.com/showthread.php?t=50701

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.