本文整理汇总了Java中org.apache.bcel.classfile.ElementValuePair类的典型用法代码示例。如果您正苦于以下问题:Java ElementValuePair类的具体用法?Java ElementValuePair怎么用?Java ElementValuePair使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ElementValuePair类属于org.apache.bcel.classfile包,在下文中一共展示了ElementValuePair类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: analyzeField
import org.apache.bcel.classfile.ElementValuePair; //导入依赖的package包/类
private void analyzeField(Field field, JavaClass javaClass) {
for (AnnotationEntry annotation : field.getAnnotationEntries()) {
if (ANNOTATION_TYPES.contains(annotation.getAnnotationType()) ||
annotation.getAnnotationType().contains("JsonTypeInfo")) {
for (ElementValuePair elementValuePair : annotation.getElementValuePairs()) {
if ("use".equals((elementValuePair.getNameString())) &&
VULNERABLE_USE_NAMES.contains(elementValuePair.getValue().stringifyValue())) {
bugReporter.reportBug(new BugInstance(this, DESERIALIZATION_TYPE, HIGH_PRIORITY)
.addClass(javaClass)
.addString(javaClass.getClassName() + " on field " +
field.getName() + " of type " + field.getType() +
" annotated with " + annotation.toShortString())
.addField(FieldAnnotation.fromBCELField(javaClass, field))
.addString("")
);
}
}
}
}
}
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:21,代码来源:UnsafeJacksonDeserializationDetector.java
示例2: isVulnerable
import org.apache.bcel.classfile.ElementValuePair; //导入依赖的package包/类
private static boolean isVulnerable(Method method) {
// If the method is not annotated with `@RequestMapping`, there is no vulnerability.
AnnotationEntry requestMappingAnnotation = findRequestMappingAnnotation(method);
if (requestMappingAnnotation == null) {
return false;
}
// If the `@RequestMapping` annotation is used without the `method` annotation attribute,
// there is a vulnerability.
ElementValuePair methodAnnotationAttribute = findMethodAnnotationAttribute(requestMappingAnnotation);
if (methodAnnotationAttribute == null) {
return true;
}
// If the `@RequestMapping` annotation is used with the `method` annotation attribute equal to `{}`,
// there is a vulnerability.
ElementValue methodAnnotationAttributeValue = methodAnnotationAttribute.getValue();
if (isEmptyArray(methodAnnotationAttributeValue)) {
return true;
}
// If the `@RequestMapping` annotation is used with the `method` annotation attribute but contains a mix of
// unprotected and protected HTTP request methods, there is a vulnerability.
return isMixOfUnprotectedAndProtectedHttpRequestMethods(methodAnnotationAttributeValue);
}
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:27,代码来源:SpringCsrfUnrestrictedRequestMappingDetector.java
示例3: addAnnotations
import org.apache.bcel.classfile.ElementValuePair; //导入依赖的package包/类
private void addAnnotations(Element node, AnnotationEntry[] annotations) {
if (annotations.length == 0) {
return;
}
Element a = new Element("annotations", nsXMLVM);
node.addContent(a);
for (AnnotationEntry annotation : annotations) {
String type = annotation.getAnnotationType();
// Turn into a scoped name. Strip off leading "L" and
// trailing
// ";"
type = type.substring(1, type.length() - 1);
type = type.replaceAll("/", ".");
Element newAnnotation = new Element("annotation", nsXMLVM);
a.addContent(newAnnotation);
newAnnotation.setAttribute("type", type);
ElementValuePair[] values = annotation.getElementValuePairs();
for (ElementValuePair value : values) {
Element property = new Element("property", nsXMLVM);
// TODO(arno) Need to add type
property.setAttribute("name", value.getNameString());
property.setAttribute("value", value.getValue().stringifyValue());
newAnnotation.addContent(property);
}
}
}
开发者ID:shannah,项目名称:cn1,代码行数:27,代码来源:ClassToXmlvmProcess.java
示例4: visitParameterAnnotation
import org.apache.bcel.classfile.ElementValuePair; //导入依赖的package包/类
@Override
public void visitParameterAnnotation(ParameterAnnotations arg0) {
ParameterAnnotationEntry[] parameterAnnotationEntries = arg0.getParameterAnnotationEntries();
int numParametersToMethod = getNumberMethodArguments();
int offset = 0;
if (numParametersToMethod > parameterAnnotationEntries.length) {
offset = 1;
}
for (int i = 0; i < parameterAnnotationEntries.length; i++) {
ParameterAnnotationEntry e = parameterAnnotationEntries[i];
for (AnnotationEntry ae : e.getAnnotationEntries()) {
boolean runtimeVisible = ae.isRuntimeVisible();
String name = ClassName.fromFieldSignature(ae.getAnnotationType());
if (name == null)
continue;
name = ClassName.toDottedClassName(name);
Map<String, ElementValue> map = new HashMap<String, ElementValue>();
for (ElementValuePair ev : ae.getElementValuePairs()) {
map.put(ev.getNameString(), ev.getValue());
}
visitParameterAnnotation(offset + i, name, map, runtimeVisible);
}
}
}
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:27,代码来源:AnnotationVisitor.java
示例5: visitAnnotation
import org.apache.bcel.classfile.ElementValuePair; //导入依赖的package包/类
@Override
public void visitAnnotation(Annotations arg0) {
for (AnnotationEntry ae : arg0.getAnnotationEntries()) {
boolean runtimeVisible = ae.isRuntimeVisible();
String name = ClassName.fromFieldSignature(ae.getAnnotationType());
if (name == null)
continue;
name = ClassName.toDottedClassName(name);
Map<String, ElementValue> map = new HashMap<String, ElementValue>();
for (ElementValuePair ev : ae.getElementValuePairs()) {
map.put(ev.getNameString(), ev.getValue());
}
visitAnnotation(name, map, runtimeVisible);
}
}
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:18,代码来源:AnnotationVisitor.java
示例6: findMethodAnnotationAttribute
import org.apache.bcel.classfile.ElementValuePair; //导入依赖的package包/类
private static ElementValuePair findMethodAnnotationAttribute(AnnotationEntry requestMappingAnnotation) {
for (ElementValuePair elementValuePair : requestMappingAnnotation.getElementValuePairs()) {
if (METHOD_ANNOTATION_ATTRIBUTE_KEY.equals(elementValuePair.getNameString())) {
return elementValuePair;
}
}
return null;
}
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:9,代码来源:SpringCsrfUnrestrictedRequestMappingDetector.java
示例7: getAttribute
import org.apache.bcel.classfile.ElementValuePair; //导入依赖的package包/类
private String getAttribute(AnnotationEntry annotationEntry, String attribute) {
for (ElementValuePair elementValuePair : annotationEntry.getElementValuePairs()) {
if(elementValuePair.getNameString().equalsIgnoreCase(attribute)) {
return elementValuePair.getValue().stringifyValue();
}
}
return "";
}
开发者ID:ralphavalon,项目名称:statement-generator,代码行数:9,代码来源:InterpretedClassFile.java
示例8: getAnnotationAttributesMap
import org.apache.bcel.classfile.ElementValuePair; //导入依赖的package包/类
private Map<String, String> getAnnotationAttributesMap(AnnotationEntry annotationEntry) {
Map<String, String> annotationsAttributesMap = new HashMap<String, String>();
for (ElementValuePair elementValuePair : annotationEntry.getElementValuePairs()) {
annotationsAttributesMap.put(elementValuePair.getNameString(), elementValuePair.getValue().stringifyValue());
}
return annotationsAttributesMap;
}
开发者ID:ralphavalon,项目名称:statement-generator,代码行数:8,代码来源:InterpretedClassFile.java
示例9: parseController
import org.apache.bcel.classfile.ElementValuePair; //导入依赖的package包/类
public static Controller parseController(AnnotationEntry annotationEntry) {
Controller controller = new Controller();
for (ElementValuePair elementValuePair : annotationEntry.getElementValuePairs()) {
if (elementValuePair.getNameString().equals("value")) {
SimpleElementValue simpleElementValue = (SimpleElementValue) elementValuePair.getValue();
controller.setValue(simpleElementValue.toShortString());
}
}
return controller;
}
开发者ID:jdepend,项目名称:cooper,代码行数:12,代码来源:AnnotationParse.java
示例10: parseService
import org.apache.bcel.classfile.ElementValuePair; //导入依赖的package包/类
public static Service parseService(AnnotationEntry annotationEntry) {
Service service = new Service();
for (ElementValuePair elementValuePair : annotationEntry.getElementValuePairs()) {
if (elementValuePair.getNameString().equals("value")) {
SimpleElementValue simpleElementValue = (SimpleElementValue) elementValuePair.getValue();
service.setValue(simpleElementValue.toShortString());
}
}
return service;
}
开发者ID:jdepend,项目名称:cooper,代码行数:12,代码来源:AnnotationParse.java
示例11: parseQualifier
import org.apache.bcel.classfile.ElementValuePair; //导入依赖的package包/类
public static Qualifier parseQualifier(AnnotationEntry annotationEntry) {
Qualifier qualifier = new Qualifier();
for (ElementValuePair elementValuePair : annotationEntry.getElementValuePairs()) {
if (elementValuePair.getNameString().equals("value")) {
SimpleElementValue simpleElementValue = (SimpleElementValue) elementValuePair.getValue();
qualifier.setValue(simpleElementValue.toShortString());
}
}
return qualifier;
}
开发者ID:jdepend,项目名称:cooper,代码行数:12,代码来源:AnnotationParse.java
示例12: parseAutowired
import org.apache.bcel.classfile.ElementValuePair; //导入依赖的package包/类
public static Autowired parseAutowired(AnnotationEntry annotationEntry) {
Autowired autowired = new Autowired();
for (ElementValuePair elementValuePair : annotationEntry.getElementValuePairs()) {
if (elementValuePair.getNameString().equals("required")) {
SimpleElementValue simpleElementValue = (SimpleElementValue) elementValuePair.getValue();
autowired.setRequired(Boolean.valueOf(simpleElementValue.toShortString()));
}
}
return autowired;
}
开发者ID:jdepend,项目名称:cooper,代码行数:12,代码来源:AnnotationParse.java
示例13: parseTable
import org.apache.bcel.classfile.ElementValuePair; //导入依赖的package包/类
public static TableInfo parseTable(AnnotationEntry annotationEntry) {
for (ElementValuePair elementValuePair : annotationEntry.getElementValuePairs()) {
if (elementValuePair.getNameString().equals("name")) {
String tableName = elementValuePair.getValue().toShortString();
if (!StringUtil.isEmpty(tableName)) {
return new TableInfo(tableName, TableInfo.Define);
}
}
}
return null;
}
开发者ID:jdepend,项目名称:cooper,代码行数:14,代码来源:AnnotationParse.java
示例14: visitMethod
import org.apache.bcel.classfile.ElementValuePair; //导入依赖的package包/类
@Override
public void visitMethod(Method method) {
xmlMethod = new Element("method", nsXMLVM);
xmlMethod.setAttribute("name", method.getName());
addAccessModifiers(xmlMethod, method.getAccessFlags());
if (!method.isAbstract() && !method.isNative()) {
// Abstract methods don't have an implementation
Code code = method.getCode();
String maxStack = java.lang.String.valueOf(code.getMaxStack());
String maxLocals = java.lang.String.valueOf(code.getMaxLocals());
xmlMethod.setAttribute("stack", maxStack);
xmlMethod.setAttribute("locals", maxLocals);
}
Element sgn = parseSignature(method.getSignature());
xmlMethod.addContent(sgn);
// TODO(arno) this should also be handled via the <annotations>
// tag.
// Need modification in xmlvm2js.xsl
// Look for NativeInterface annotation
for (AnnotationEntry annotation : method.getAnnotationEntries()) {
String type = annotation.getAnnotationType();
if (type.equals("Lorg/xmlvm/NativeInterface;")) {
ElementValuePair[] value = annotation.getElementValuePairs();
String nativeMethodName = value[0].getValue().toString();
xmlMethod.setAttribute("nativeInterface", nativeMethodName);
break;
}
}
addAnnotations(xmlMethod, method.getAnnotationEntries());
xmlClass.addContent(xmlMethod);
this.bcelMethod = method;
}
开发者ID:shannah,项目名称:cn1,代码行数:34,代码来源:ClassToXmlvmProcess.java
注:本文中的org.apache.bcel.classfile.ElementValuePair类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论