diff --git a/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/ModelPrompt.qll b/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/ModelPrompt.qll new file mode 100644 index 00000000000..c7e02db732d --- /dev/null +++ b/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/ModelPrompt.qll @@ -0,0 +1,81 @@ +import javascript + +module ModelPrompt { + string getPrompt(DataFlow::Node endpoint) { + result = getTrainingSetPrompt() + getCurrentEndpointPrompt(endpoint) + } + + /** + * Gets the beginning of the prompt, which contains the training examples, shuffled in random order. + * This part of the prompt was generated from examples that come from training repos rather than evaluation repos. + * These are diverse examples generated from a random selection of repos in the ATM training set. + * Each example is from a different repo. There are two examples of each sink type and eight non-sink examples, each + * from a different negative endpoint characteristic. + */ + private string getTrainingSetPrompt() { + result = + "# Examples of security vulnerability sinks and non-sinks\n|Dataflow node|Neighborhood|Classification|\n|---|---|---|\n|`WPUrls.ajaxurl`|` dataType: json , type: POST , url: WPUrls.ajaxurl, data: data, complete: function( json ) {`|non-sink|\n|`[ handlebars ]`|` use strict ; if (typeof define === function && define.amd) { define([ handlebars ], function(Handlebars) { return factory(Handlebars.default Handlebars); });`|path injection sink|\n|`url`|`} else { var matcher = new RegExp($.map(items.wanikanify_blackList, function(val) { return ( +val+ ) ;}).join( )); return matcher.test(url); } }`|non-sink|\n|`_.bind(connection.createGame, this, socket)`|`var connection = module.exports = function (socket) { socket.on( game:create , _.bind(connection.createGame, this, socket)); socket.on( game:spectate , _.bind(game.spectate, this, socket)); socket.on( register , _.bind(connection.register, this, socket));`|non-sink|\n|`sql`|` if (err) throw err; const sql = UPDATE customers SET address = Canyon 123 WHERE address = Valley 345 ; con.query(sql, function (err, result) { if (err) throw err; console.log(result.affectedRows + record(s) updated );`|sql injection sink|\n|` `|` if ( ! style.length ) { style = $( head ).append( ).find( #shapely-style- + sufix ); }`|xss sink|\n|`content`|` textBoxEditor(content) { console.log(content); } ngOnInit() {`|non-sink|\n|`imageURL`|`