Skip to content

Commit

Permalink
something in 51ec8fd broke something, this branch is debugging it
Browse files Browse the repository at this point in the history
  • Loading branch information
mmguero committed May 18, 2021
1 parent 51ec8fd commit 292186c
Showing 1 changed file with 37 additions and 23 deletions.
60 changes: 37 additions & 23 deletions analyzer/protocol/ldap/ldap.spicy
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ public type Message = unit {
};
# TODO: add support for switch-level &parse-from/&parse-at
# https://github.com/zeek/spicy/issues/913

} &requires=((self?.messageID) && (self?.opcode) && (self.opcode != ProtocolOpcode::NOT_SET));

#-----------------------------------------------------------------------------
Expand All @@ -203,36 +204,36 @@ type SaslCredentials = unit() {
};

type BindRequest = unit(inout message: Message) {

version: asn1::ASN1Message(True) &convert=$$.body.num_value;
name: asn1::ASN1Message(True) &convert=$$.body.str_value {
message.obj = self.name;
}
var authType: BindAuthType = BindAuthType::NOT_SET;
var simpleCreds: string = "";
var saslData: bytes;

: asn1::ASN1Message(True) {
if ($$?.application_id) {
self.authType = cast<BindAuthType>(cast<uint8>($$.application_id));
authentication: asn1::ASN1Message(True) {
if (self.authentication?.application_id) {
self.authType = cast<BindAuthType>(cast<uint8>(self.authentication.application_id));
}
if ((self.authType == BindAuthType::BIND_AUTH_SIMPLE) &&
(|$$.application_data| > 0)) {
self.simpleCreds = $$.application_data.decode();
(|self.authentication.application_data| > 0)) {
self.simpleCreds = self.authentication.application_data.decode();
if (|self.simpleCreds| > 0) {
message.arg = self.simpleCreds;
}
} else {
self.saslData == $$.application_data;
}
}
saslCreds: SaslCredentials() &parse-from=self.saslData if (self?.saslData) {
saslCreds: SaslCredentials() &parse-from=self.authentication.application_data if (self.authType == BindAuthType::BIND_AUTH_SASL) {
message.arg = self.saslCreds.mechanism;
}

} &requires=((self?.authType) && (self.authType != BindAuthType::NOT_SET));

type BindResponse = unit(inout message: Message) {
: Result {
message.result = $$;

result: Result {
message.result = self.result;
}

# TODO: if we want to parse SASL credentials returned
Expand Down Expand Up @@ -317,6 +318,7 @@ type AttributeValueAssertion = unit() {
}
}
}

};

type SubstringFilter = unit() {
Expand All @@ -339,6 +341,7 @@ type SubstringFilter = unit() {
#
#}
}

};

type SearchFilter = unit() {
Expand Down Expand Up @@ -388,6 +391,7 @@ type SearchFilter = unit() {
};

type SearchRequest = unit(inout message: Message) {

baseObject: asn1::ASN1Message(True) &convert=$$.body.str_value {
message.obj = self.baseObject;
}
Expand All @@ -405,16 +409,19 @@ type SearchRequest = unit(inout message: Message) {
};

type SearchResultEntry = unit(inout message: Message) {

objectName: asn1::ASN1Message(True) &convert=$$.body.str_value {
message.obj = self.objectName;
}
# TODO: if we want to descend down into PartialAttributeList
attributes: asn1::ASN1Message(True);

};

type SearchResultDone = unit(inout message: Message) {
: Result {
message.result = $$;

result: Result {
message.result = self.result;
}
};

Expand All @@ -428,6 +435,7 @@ type SearchResultDone = unit(inout message: Message) {
# https://tools.ietf.org/html/rfc4511#section-4.6

type ModifyRequest = unit(inout message: Message) {

objectName: asn1::ASN1Message(True) &convert=$$.body.str_value {
message.obj = self.objectName;
}
Expand All @@ -436,8 +444,9 @@ type ModifyRequest = unit(inout message: Message) {
};

type ModifyResponse = unit(inout message: Message) {
: Result {
message.result = $$;

result: Result {
message.result = self.result;
}
};

Expand All @@ -452,8 +461,9 @@ type ModifyResponse = unit(inout message: Message) {
# };

type AddResponse = unit(inout message: Message) {
: Result {
message.result = $$;

result: Result {
message.result = self.result;
}
};

Expand All @@ -462,14 +472,16 @@ type AddResponse = unit(inout message: Message) {
# https://tools.ietf.org/html/rfc4511#section-4.8

type DelRequest = unit(inout message: Message) {

objectName: asn1::ASN1Message(True) &convert=$$.body.str_value {
message.obj = self.objectName;
}
};

type DelResponse = unit(inout message: Message) {
: Result {
message.result = $$;

result: Result {
message.result = self.result;
}
};

Expand All @@ -483,8 +495,9 @@ type DelResponse = unit(inout message: Message) {
# };

type ModDNResponse = unit(inout message: Message) {
: Result {
message.result = $$;

result: Result {
message.result = self.result;
}
};

Expand All @@ -498,8 +511,9 @@ type ModDNResponse = unit(inout message: Message) {
# };

type CompareResponse = unit(inout message: Message) {
: Result {
message.result = $$;

result: Result {
message.result = self.result;
}
};

Expand Down

0 comments on commit 292186c

Please sign in to comment.