code-injection

Grails: Getting the Data Source in a normal groovy class

十年热恋 提交于 2019-12-04 21:02:56
问题 How can I get access to the data source from within a normal groovy class? Injection doesn't work like it does with services. The reason for this is that I need to do some manual database calls (ie: SQL statements using the groovy.sql.Sql class) from the groovy class since I'm working with a legacy database. 回答1: dataSource is a bean which gets auto injected in services when used. All beans are auto wired in grails artifacts (controllers, services etc) by default. In your case you are using a

CDI - ApplicationScoped but configured

℡╲_俬逩灬. 提交于 2019-12-04 20:43:45
Problem Using CDI I want to produce @ApplicationScoped beans. Additionally I want to provide a configuration annotation to the injection points, e.g.: @Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) @Retention(RetentionPolicy.RUNTIME) public @interface Configuration { String value(); } I do not want to write a separate producer for each different possibility of value . Approach The usual way would be to make a producer and handle the injection point annotations: @Produces public Object create(InjectionPoint injectionPoint) { Configuration annotation = injectionPoint

Having trouble with microsoft detours

只愿长相守 提交于 2019-12-04 20:24:25
I'm trying to do some basic hooking with microsoft detours and I can't get it to work. I've used essentially the code that was posted in this thread: How can I hook Windows functions in C/C++? but no dice. I updated the send/receive functions in the DLL code to simply log the data to a file, and I tried having the main program hook into the "internet checkers" program, but a log file never gets created, so it appears that the dll wasn't injected. I'm running Windows 7 64-bit, Visual Studio 10.0, Detours 3.0 (my environment appears to be set up correctly, no issues building or anything). I

Testing controller with injected service inside angularJS with jasmine

谁说胖子不能爱 提交于 2019-12-04 20:00:52
问题 I am trying to understand how to test my code with jasmine and angularJS. I wrote a test project with a controller and an injected service. Now i want to test the controller and tried to mock the injected service. But i didn’t found a way to test the function “Arrived” from my controller. Here’s my jsfiddle: http://jsfiddle.net/2fwxS/ controller.js: angular.module('myApp.controllers', []) .controller('MyCtrl', ['$scope', 'MyService', function ($scope, MyService) { $scope.User = {}; $scope

How to stop HTTP (and rfc822, email) header injection?

杀马特。学长 韩版系。学妹 提交于 2019-12-04 18:23:04
(I am asking this question (and answering it), to make accessible some (hopefully useful) information, since I could not find this readily using search engines. However, feel free to answer it and add useful information :-).) How can HTTP headers be escaped/quoted in Python? And/Or how can they be validated to make sure they do not contain any context-escaping values? In other words, how can we do for HTTP headers, what cgi.escape and urllib.quote methods (and sanitizing) do for HTML and URLs? This can be used to guard against HTTP header injection and similar exploits. For example... We have

Angularjs custom filter and dependency injection

送分小仙女□ 提交于 2019-12-04 16:35:05
问题 I'm new to AngularJS and i see this syntax a lot: function someFunc(){ return function(input){ return 'hello' + input; } } The function above is a general syntax i tend to see a lot but problem is specific with this example for custom filter: angular.module('bookFilters', []) .filter('newBookFilter', function(){ return function(input){ return 'The Book: ' + input.name + 'is new !'; }; }); I understand that wrapping the function with another function gives me an opportunity to use dependency

Injecting same EJB into two different managed beans not working

眉间皱痕 提交于 2019-12-04 14:55:53
问题 I have a stateless EJB and two different SessionScoped managed beans. e.g. EJB as follows - @Stateless public classs MyEjb implements MyEjbLocal { @PersistentContext(unitName="myPU") private EntityManager em; and a managed bean - @ManagedBean @SessionScoped public class MyBean1 implements Serializable { @EJB private MyEjbLocal myEjb; and another managed bean - @ManagedBean @SessionScoped public class MyBean2 implements Serilizable { @EJB private MyEjbLocal myEjb; private List<MyEntity>

Are Cookies a Security Risk?

谁说胖子不能爱 提交于 2019-12-04 14:43:44
Assume we have a website that asks the user for his name. The website then stores this value in a cookie, and on the next page, retrieves it via PHP and uses it somehow (perhaps the page displays the name as text). Could a user modify the cookie data to inject malicious code? Should cookie data be sanitized as it's retrieved by the script? (This is a hypothetical scenario. Obviously a cookie wouldn't be necessary here.) Could a user modify the cookie data to inject malicious code? Should cookies be sanitized as they're retrieved by the script? Inject malicious code? Not PHP code, but you are

Ansi C patch using dlsym compiles OK under linux but fails on Mac Os X

随声附和 提交于 2019-12-04 13:10:37
I have build a little patch to append to a certain application and trace the invocations of some functions. Among them, malloc() and open(). I am using dlsym to store the pointer to the original symbol and replace the function name with my own. It compiles -and works- perfectly under linux. Here's the code: #define _GNU_SOURCE #include <stdint.h> #include <stdio.h> #include <string.h> #include <stdarg.h> #include <dlfcn.h> /** * Interponemos nuestra funcion open * * @param char* filename * @param int flags **/ int open(char * filename, int flags) { static int (*real_open)(char*, int) = NULL;

Permission: INJECT_EVENTS for Instrumenation to other apps

断了今生、忘了曾经 提交于 2019-12-04 12:11:42
问题 I know that this is not the first Thread about this permission, however the other ones aren't finished or don't help me. What I need is to inflate KeyEvents using Instrumentation. That works great and is insanely faster than the shell ("input keyevent ") method. But if I want to inject to other apps I catch a SecurityException. That didn't surprise me to much so I added <uses-permission android:name="android.permission.INJECT_EVENTS" /> to my manifest. Eclipse stops to debug this telling me