mirror of
https://github.com/denoland/deno.git
synced 2025-01-20 20:42:19 -05:00
Compare commits
8 commits
a1a519a4f4
...
269125948c
Author | SHA1 | Date | |
---|---|---|---|
|
269125948c | ||
|
0d3d4f5466 | ||
|
5e9b3712de | ||
|
395628026f | ||
|
4f27d7cdc0 | ||
|
917e52c882 | ||
|
c09deecac1 | ||
|
a4a44e2ad0 |
21 changed files with 343 additions and 50 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -2032,6 +2032,7 @@ dependencies = [
|
|||
"bytes",
|
||||
"cbc",
|
||||
"const-oid",
|
||||
"ctr",
|
||||
"data-encoding",
|
||||
"deno_core",
|
||||
"deno_error",
|
||||
|
|
|
@ -122,6 +122,7 @@ cbc = { version = "=0.1.2", features = ["alloc"] }
|
|||
chrono = { version = "0.4", default-features = false, features = ["std", "serde"] }
|
||||
color-print = "0.3.5"
|
||||
console_static_text = "=0.8.1"
|
||||
ctr = { version = "0.9.2", features = ["alloc"] }
|
||||
dashmap = "5.5.3"
|
||||
data-encoding = "2.3.3"
|
||||
data-url = "=0.3.1"
|
||||
|
|
|
@ -115,10 +115,16 @@ exec deno {} "$@"
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn get_installer_root() -> Result<PathBuf, io::Error> {
|
||||
if let Ok(env_dir) = env::var("DENO_INSTALL_ROOT") {
|
||||
fn get_installer_root() -> Result<PathBuf, AnyError> {
|
||||
if let Some(env_dir) = env::var_os("DENO_INSTALL_ROOT") {
|
||||
if !env_dir.is_empty() {
|
||||
return canonicalize_path_maybe_not_exists(&PathBuf::from(env_dir));
|
||||
let env_dir = PathBuf::from(env_dir);
|
||||
return canonicalize_path_maybe_not_exists(&env_dir).with_context(|| {
|
||||
format!(
|
||||
"Canonicalizing DENO_INSTALL_ROOT ('{}').",
|
||||
env_dir.display()
|
||||
)
|
||||
});
|
||||
}
|
||||
}
|
||||
// Note: on Windows, the $HOME environment variable may be set by users or by
|
||||
|
@ -587,11 +593,22 @@ async fn resolve_shim_data(
|
|||
let copy_path = get_hidden_file_with_ext(&file_path, "deno.json");
|
||||
executable_args.push("--config".to_string());
|
||||
executable_args.push(copy_path.to_str().unwrap().to_string());
|
||||
extra_files.push((
|
||||
copy_path,
|
||||
fs::read_to_string(config_path)
|
||||
.with_context(|| format!("error reading {config_path}"))?,
|
||||
));
|
||||
let mut config_text = fs::read_to_string(config_path)
|
||||
.with_context(|| format!("error reading {config_path}"))?;
|
||||
// always remove the import map field because when someone specifies `--import-map` we
|
||||
// don't want that file to be attempted to be loaded and when they don't specify that
|
||||
// (which is just something we haven't implemented yet)
|
||||
if let Some(new_text) = remove_import_map_field_from_text(&config_text) {
|
||||
if flags.import_map_path.is_none() {
|
||||
log::warn!(
|
||||
"{} \"importMap\" field in the specified config file we be ignored. Use the --import-map flag instead.",
|
||||
crate::colors::yellow("Warning"),
|
||||
);
|
||||
}
|
||||
config_text = new_text;
|
||||
}
|
||||
|
||||
extra_files.push((copy_path, config_text));
|
||||
} else {
|
||||
executable_args.push("--no-config".to_string());
|
||||
}
|
||||
|
@ -631,6 +648,16 @@ async fn resolve_shim_data(
|
|||
})
|
||||
}
|
||||
|
||||
fn remove_import_map_field_from_text(config_text: &str) -> Option<String> {
|
||||
let value =
|
||||
jsonc_parser::cst::CstRootNode::parse(config_text, &Default::default())
|
||||
.ok()?;
|
||||
let root_value = value.object_value()?;
|
||||
let import_map_value = root_value.get("importMap")?;
|
||||
import_map_value.remove();
|
||||
Some(value.to_string())
|
||||
}
|
||||
|
||||
fn get_hidden_file_with_ext(file_path: &Path, ext: &str) -> PathBuf {
|
||||
// use a dot file to prevent the file from showing up in some
|
||||
// users shell auto-complete since this directory is on the PATH
|
||||
|
@ -1585,4 +1612,17 @@ mod tests {
|
|||
assert!(!file_path.exists());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_remove_import_map_field_from_text() {
|
||||
assert_eq!(
|
||||
remove_import_map_field_from_text(
|
||||
r#"{
|
||||
"importMap": "./value.json"
|
||||
}"#,
|
||||
)
|
||||
.unwrap(),
|
||||
"{}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ aes-kw = { version = "0.2.1", features = ["alloc"] }
|
|||
base64.workspace = true
|
||||
cbc.workspace = true
|
||||
const-oid = "0.9.0"
|
||||
ctr = "0.9.1"
|
||||
ctr.workspace = true
|
||||
curve25519-dalek = "4.1.3"
|
||||
deno_core.workspace = true
|
||||
deno_error.workspace = true
|
||||
|
|
|
@ -27,6 +27,7 @@ brotli.workspace = true
|
|||
bytes.workspace = true
|
||||
cbc.workspace = true
|
||||
const-oid = "0.9.5"
|
||||
ctr.workspace = true
|
||||
data-encoding.workspace = true
|
||||
deno_core.workspace = true
|
||||
deno_error.workspace = true
|
||||
|
|
|
@ -226,7 +226,6 @@ deno_core::extension!(deno_node,
|
|||
ops::crypto::op_node_decipheriv_decrypt,
|
||||
ops::crypto::op_node_decipheriv_final,
|
||||
ops::crypto::op_node_decipheriv_set_aad,
|
||||
ops::crypto::op_node_decipheriv_take,
|
||||
ops::crypto::op_node_dh_compute_secret,
|
||||
ops::crypto::op_node_diffie_hellman,
|
||||
ops::crypto::op_node_ecdh_compute_public_key,
|
||||
|
|
|
@ -8,6 +8,7 @@ use aes::cipher::block_padding::Pkcs7;
|
|||
use aes::cipher::BlockDecryptMut;
|
||||
use aes::cipher::BlockEncryptMut;
|
||||
use aes::cipher::KeyIvInit;
|
||||
use aes::cipher::StreamCipher;
|
||||
use deno_core::Resource;
|
||||
use digest::generic_array::GenericArray;
|
||||
use digest::KeyInit;
|
||||
|
@ -25,6 +26,8 @@ enum Cipher {
|
|||
Aes128Gcm(Box<Aes128Gcm>),
|
||||
Aes256Gcm(Box<Aes256Gcm>),
|
||||
Aes256Cbc(Box<cbc::Encryptor<aes::Aes256>>),
|
||||
Aes128Ctr(Box<ctr::Ctr128BE<aes::Aes128>>),
|
||||
Aes256Ctr(Box<ctr::Ctr128BE<aes::Aes256>>),
|
||||
// TODO(kt3k): add more algorithms Aes192Cbc, etc.
|
||||
}
|
||||
|
||||
|
@ -36,6 +39,8 @@ enum Decipher {
|
|||
Aes128Gcm(Box<Aes128Gcm>),
|
||||
Aes256Gcm(Box<Aes256Gcm>),
|
||||
Aes256Cbc(Box<cbc::Decryptor<aes::Aes256>>),
|
||||
Aes256Ctr(Box<ctr::Ctr128BE<aes::Aes256>>),
|
||||
Aes128Ctr(Box<ctr::Ctr128BE<aes::Aes128>>),
|
||||
// TODO(kt3k): add more algorithms Aes192Cbc, Aes128GCM, etc.
|
||||
}
|
||||
|
||||
|
@ -211,6 +216,24 @@ impl Cipher {
|
|||
|
||||
Aes256Cbc(Box::new(cbc::Encryptor::new(key.into(), iv.into())))
|
||||
}
|
||||
"aes-256-ctr" => {
|
||||
if key.len() != 32 {
|
||||
return Err(CipherError::InvalidKeyLength);
|
||||
}
|
||||
if iv.len() != 16 {
|
||||
return Err(CipherError::InvalidInitializationVector);
|
||||
}
|
||||
Aes256Ctr(Box::new(ctr::Ctr128BE::new(key.into(), iv.into())))
|
||||
}
|
||||
"aes-128-ctr" => {
|
||||
if key.len() != 16 {
|
||||
return Err(CipherError::InvalidKeyLength);
|
||||
}
|
||||
if iv.len() != 16 {
|
||||
return Err(CipherError::InvalidInitializationVector);
|
||||
}
|
||||
Aes128Ctr(Box::new(ctr::Ctr128BE::new(key.into(), iv.into())))
|
||||
}
|
||||
_ => return Err(CipherError::UnknownCipher(algorithm_name.to_string())),
|
||||
})
|
||||
}
|
||||
|
@ -270,6 +293,12 @@ impl Cipher {
|
|||
encryptor.encrypt_block_b2b_mut(input.into(), output.into());
|
||||
}
|
||||
}
|
||||
Aes256Ctr(encryptor) => {
|
||||
encryptor.apply_keystream_b2b(input, output).unwrap();
|
||||
}
|
||||
Aes128Ctr(encryptor) => {
|
||||
encryptor.apply_keystream_b2b(input, output).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -350,6 +379,7 @@ impl Cipher {
|
|||
);
|
||||
Ok(None)
|
||||
}
|
||||
(Aes256Ctr(_) | Aes128Ctr(_), _) => Ok(None),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -405,6 +435,12 @@ impl Decipher {
|
|||
"aes-128-ecb" => Aes128Ecb(Box::new(ecb::Decryptor::new(key.into()))),
|
||||
"aes-192-ecb" => Aes192Ecb(Box::new(ecb::Decryptor::new(key.into()))),
|
||||
"aes-256-ecb" => Aes256Ecb(Box::new(ecb::Decryptor::new(key.into()))),
|
||||
"aes-256-ctr" => {
|
||||
Aes256Ctr(Box::new(ctr::Ctr128BE::new(key.into(), iv.into())))
|
||||
}
|
||||
"aes-128-ctr" => {
|
||||
Aes128Ctr(Box::new(ctr::Ctr128BE::new(key.into(), iv.into())))
|
||||
}
|
||||
"aes-128-gcm" => {
|
||||
let decipher =
|
||||
aead_gcm_stream::AesGcm::<aes::Aes128>::new(key.into(), iv);
|
||||
|
@ -488,6 +524,12 @@ impl Decipher {
|
|||
decryptor.decrypt_block_b2b_mut(input.into(), output.into());
|
||||
}
|
||||
}
|
||||
Aes256Ctr(decryptor) => {
|
||||
decryptor.apply_keystream_b2b(input, output).unwrap();
|
||||
}
|
||||
Aes128Ctr(decryptor) => {
|
||||
decryptor.apply_keystream_b2b(input, output).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -500,6 +542,11 @@ impl Decipher {
|
|||
auth_tag: &[u8],
|
||||
) -> Result<(), DecipherError> {
|
||||
use Decipher::*;
|
||||
|
||||
if input.is_empty() && !matches!(self, Aes128Gcm(_) | Aes256Gcm(_)) {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
match (self, auto_pad) {
|
||||
(Aes128Cbc(decryptor), true) => {
|
||||
assert!(input.len() == 16);
|
||||
|
@ -593,6 +640,14 @@ impl Decipher {
|
|||
);
|
||||
Ok(())
|
||||
}
|
||||
(Aes256Ctr(mut decryptor), _) => {
|
||||
decryptor.apply_keystream_b2b(input, output).unwrap();
|
||||
Ok(())
|
||||
}
|
||||
(Aes128Ctr(mut decryptor), _) => {
|
||||
decryptor.apply_keystream_b2b(input, output).unwrap();
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -332,17 +332,6 @@ pub fn op_node_decipheriv_decrypt(
|
|||
true
|
||||
}
|
||||
|
||||
#[op2(fast)]
|
||||
pub fn op_node_decipheriv_take(
|
||||
state: &mut OpState,
|
||||
#[smi] rid: u32,
|
||||
) -> Result<(), cipher::DecipherContextError> {
|
||||
let context = state.resource_table.take::<cipher::DecipherContext>(rid)?;
|
||||
Rc::try_unwrap(context)
|
||||
.map_err(|_| cipher::DecipherContextError::ContextInUse)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[op2]
|
||||
pub fn op_node_decipheriv_final(
|
||||
state: &mut OpState,
|
||||
|
|
|
@ -18,7 +18,6 @@ import {
|
|||
op_node_decipheriv_decrypt,
|
||||
op_node_decipheriv_final,
|
||||
op_node_decipheriv_set_aad,
|
||||
op_node_decipheriv_take,
|
||||
op_node_private_decrypt,
|
||||
op_node_private_encrypt,
|
||||
op_node_public_encrypt,
|
||||
|
@ -187,7 +186,8 @@ export class Cipheriv extends Transform implements Cipher {
|
|||
this.#cache = new BlockModeCache(false);
|
||||
this.#context = op_node_create_cipheriv(cipher, toU8(key), toU8(iv));
|
||||
this.#needsBlockCache =
|
||||
!(cipher == "aes-128-gcm" || cipher == "aes-256-gcm");
|
||||
!(cipher == "aes-128-gcm" || cipher == "aes-256-gcm" ||
|
||||
cipher == "aes-128-ctr" || cipher == "aes-256-ctr");
|
||||
if (this.#context == 0) {
|
||||
throw new TypeError("Unknown cipher");
|
||||
}
|
||||
|
@ -345,21 +345,14 @@ export class Decipheriv extends Transform implements Cipher {
|
|||
this.#cache = new BlockModeCache(this.#autoPadding);
|
||||
this.#context = op_node_create_decipheriv(cipher, toU8(key), toU8(iv));
|
||||
this.#needsBlockCache =
|
||||
!(cipher == "aes-128-gcm" || cipher == "aes-256-gcm");
|
||||
!(cipher == "aes-128-gcm" || cipher == "aes-256-gcm" ||
|
||||
cipher == "aes-128-ctr" || cipher == "aes-256-ctr");
|
||||
if (this.#context == 0) {
|
||||
throw new TypeError("Unknown cipher");
|
||||
}
|
||||
}
|
||||
|
||||
final(encoding: string = getDefaultEncoding()): Buffer | string {
|
||||
if (!this.#needsBlockCache || this.#cache.cache.byteLength === 0) {
|
||||
op_node_decipheriv_take(this.#context);
|
||||
return encoding === "buffer" ? Buffer.from([]) : "";
|
||||
}
|
||||
if (this.#cache.cache.byteLength != 16) {
|
||||
throw new Error("Invalid final block size");
|
||||
}
|
||||
|
||||
let buf = new Buffer(16);
|
||||
op_node_decipheriv_final(
|
||||
this.#context,
|
||||
|
@ -369,6 +362,13 @@ export class Decipheriv extends Transform implements Cipher {
|
|||
this.#authTag || NO_TAG,
|
||||
);
|
||||
|
||||
if (!this.#needsBlockCache || this.#cache.cache.byteLength === 0) {
|
||||
return encoding === "buffer" ? Buffer.from([]) : "";
|
||||
}
|
||||
if (this.#cache.cache.byteLength != 16) {
|
||||
throw new Error("Invalid final block size");
|
||||
}
|
||||
|
||||
buf = buf.subarray(0, 16 - buf.at(-1)); // Padded in Pkcs7 mode
|
||||
return encoding === "buffer" ? buf : buf.toString(encoding);
|
||||
}
|
||||
|
|
|
@ -116,6 +116,12 @@ deno_core::extension!(
|
|||
"op_exit" | "op_set_exit_code" | "op_get_exit_code" =>
|
||||
op.with_implementation_from(&deno_core::op_void_sync()),
|
||||
_ => op,
|
||||
},
|
||||
state = |state| {
|
||||
#[cfg(unix)]
|
||||
{
|
||||
state.put(ops::signal::SignalState::default());
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ use opentelemetry::metrics::InstrumentBuilder;
|
|||
use opentelemetry::metrics::MeterProvider as _;
|
||||
use opentelemetry::otel_debug;
|
||||
use opentelemetry::otel_error;
|
||||
use opentelemetry::trace::Link;
|
||||
use opentelemetry::trace::SpanContext;
|
||||
use opentelemetry::trace::SpanId;
|
||||
use opentelemetry::trace::SpanKind;
|
||||
|
@ -94,6 +95,7 @@ deno_core::extension!(
|
|||
op_otel_span_attribute1,
|
||||
op_otel_span_attribute2,
|
||||
op_otel_span_attribute3,
|
||||
op_otel_span_add_link,
|
||||
op_otel_span_update_name,
|
||||
op_otel_metric_attribute3,
|
||||
op_otel_metric_record0,
|
||||
|
@ -1324,17 +1326,6 @@ impl OtelSpan {
|
|||
}
|
||||
}
|
||||
|
||||
#[fast]
|
||||
fn drop_link(&self) {
|
||||
let mut state = self.0.borrow_mut();
|
||||
match &mut **state {
|
||||
OtelSpanState::Recording(span) => {
|
||||
span.links.dropped_count += 1;
|
||||
}
|
||||
OtelSpanState::Done(_) => {}
|
||||
}
|
||||
}
|
||||
|
||||
#[fast]
|
||||
fn end(&self, end_time: f64) {
|
||||
let end_time = if end_time.is_nan() {
|
||||
|
@ -1448,6 +1439,48 @@ fn op_otel_span_update_name<'s>(
|
|||
}
|
||||
}
|
||||
|
||||
#[op2(fast)]
|
||||
fn op_otel_span_add_link<'s>(
|
||||
scope: &mut v8::HandleScope<'s>,
|
||||
span: v8::Local<'s, v8::Value>,
|
||||
trace_id: v8::Local<'s, v8::Value>,
|
||||
span_id: v8::Local<'s, v8::Value>,
|
||||
#[smi] trace_flags: u8,
|
||||
is_remote: bool,
|
||||
#[smi] dropped_attributes_count: u32,
|
||||
) -> bool {
|
||||
let trace_id = parse_trace_id(scope, trace_id);
|
||||
if trace_id == TraceId::INVALID {
|
||||
return false;
|
||||
};
|
||||
let span_id = parse_span_id(scope, span_id);
|
||||
if span_id == SpanId::INVALID {
|
||||
return false;
|
||||
};
|
||||
let span_context = SpanContext::new(
|
||||
trace_id,
|
||||
span_id,
|
||||
TraceFlags::new(trace_flags),
|
||||
is_remote,
|
||||
TraceState::NONE,
|
||||
);
|
||||
|
||||
let Some(span) =
|
||||
deno_core::_ops::try_unwrap_cppgc_object::<OtelSpan>(scope, span)
|
||||
else {
|
||||
return true;
|
||||
};
|
||||
let mut state = span.0.borrow_mut();
|
||||
if let OtelSpanState::Recording(span) = &mut **state {
|
||||
span.links.links.push(Link::new(
|
||||
span_context,
|
||||
vec![],
|
||||
dropped_attributes_count,
|
||||
));
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
struct OtelMeter(opentelemetry::metrics::Meter);
|
||||
|
||||
impl deno_core::GarbageCollected for OtelMeter {}
|
||||
|
|
|
@ -15,6 +15,7 @@ import {
|
|||
op_otel_metric_record2,
|
||||
op_otel_metric_record3,
|
||||
op_otel_metric_wait_to_observe,
|
||||
op_otel_span_add_link,
|
||||
op_otel_span_attribute1,
|
||||
op_otel_span_attribute2,
|
||||
op_otel_span_attribute3,
|
||||
|
@ -186,7 +187,6 @@ interface OtelSpan {
|
|||
spanContext(): SpanContext;
|
||||
setStatus(status: SpanStatusCode, errorDescription: string): void;
|
||||
dropEvent(): void;
|
||||
dropLink(): void;
|
||||
end(endTime: number): void;
|
||||
}
|
||||
|
||||
|
@ -359,14 +359,24 @@ class Span {
|
|||
return this;
|
||||
}
|
||||
|
||||
addLink(_link: Link): Span {
|
||||
this.#otelSpan?.dropLink();
|
||||
addLink(link: Link): Span {
|
||||
const droppedAttributeCount = (link.droppedAttributesCount ?? 0) +
|
||||
(link.attributes ? ObjectKeys(link.attributes).length : 0);
|
||||
const valid = op_otel_span_add_link(
|
||||
this.#otelSpan,
|
||||
link.context.traceId,
|
||||
link.context.spanId,
|
||||
link.context.traceFlags,
|
||||
link.context.isRemote ?? false,
|
||||
droppedAttributeCount,
|
||||
);
|
||||
if (!valid) return this;
|
||||
return this;
|
||||
}
|
||||
|
||||
addLinks(links: Link[]): Span {
|
||||
for (let i = 0; i < links.length; i++) {
|
||||
this.#otelSpan?.dropLink();
|
||||
this.addLink(links[i]);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,10 @@
|
|||
},
|
||||
"args": "run -A main.ts metric.ts",
|
||||
"output": "metric.out"
|
||||
},
|
||||
"links": {
|
||||
"args": "run -A main.ts links.ts",
|
||||
"output": "links.out"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
96
tests/specs/cli/otel_basic/links.out
Normal file
96
tests/specs/cli/otel_basic/links.out
Normal file
|
@ -0,0 +1,96 @@
|
|||
{
|
||||
"spans": [
|
||||
{
|
||||
"traceId": "00000000000000000000000000000001",
|
||||
"spanId": "0000000000000001",
|
||||
"traceState": "",
|
||||
"parentSpanId": "",
|
||||
"flags": 1,
|
||||
"name": "example span",
|
||||
"kind": 1,
|
||||
"startTimeUnixNano": "[WILDCARD]",
|
||||
"endTimeUnixNano": "[WILDCARD]",
|
||||
"attributes": [],
|
||||
"droppedAttributesCount": 0,
|
||||
"events": [],
|
||||
"droppedEventsCount": 0,
|
||||
"links": [
|
||||
{
|
||||
"traceId": "1234567890abcdef1234567890abcdef",
|
||||
"spanId": "1234567890abcdef",
|
||||
"traceState": "",
|
||||
"attributes": [],
|
||||
"droppedAttributesCount": 0,
|
||||
"flags": 1
|
||||
}
|
||||
],
|
||||
"droppedLinksCount": 0,
|
||||
"status": {
|
||||
"message": "",
|
||||
"code": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"traceId": "00000000000000000000000000000002",
|
||||
"spanId": "0000000000000002",
|
||||
"traceState": "",
|
||||
"parentSpanId": "",
|
||||
"flags": 1,
|
||||
"name": "example span",
|
||||
"kind": 1,
|
||||
"startTimeUnixNano": "[WILDCARD]",
|
||||
"endTimeUnixNano": "[WILDCARD]",
|
||||
"attributes": [],
|
||||
"droppedAttributesCount": 0,
|
||||
"events": [],
|
||||
"droppedEventsCount": 0,
|
||||
"links": [
|
||||
{
|
||||
"traceId": "1234567890abcdef1234567890abcdef",
|
||||
"spanId": "1234567890abcdef",
|
||||
"traceState": "",
|
||||
"attributes": [],
|
||||
"droppedAttributesCount": 0,
|
||||
"flags": 1
|
||||
}
|
||||
],
|
||||
"droppedLinksCount": 0,
|
||||
"status": {
|
||||
"message": "",
|
||||
"code": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"traceId": "00000000000000000000000000000003",
|
||||
"spanId": "0000000000000003",
|
||||
"traceState": "",
|
||||
"parentSpanId": "",
|
||||
"flags": 1,
|
||||
"name": "example span",
|
||||
"kind": 1,
|
||||
"startTimeUnixNano": "[WILDCARD]",
|
||||
"endTimeUnixNano": "[WILDCARD]",
|
||||
"attributes": [],
|
||||
"droppedAttributesCount": 0,
|
||||
"events": [],
|
||||
"droppedEventsCount": 0,
|
||||
"links": [
|
||||
{
|
||||
"traceId": "1234567890abcdef1234567890abcdef",
|
||||
"spanId": "1234567890abcdef",
|
||||
"traceState": "",
|
||||
"attributes": [],
|
||||
"droppedAttributesCount": 2,
|
||||
"flags": 1
|
||||
}
|
||||
],
|
||||
"droppedLinksCount": 0,
|
||||
"status": {
|
||||
"message": "",
|
||||
"code": 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"logs": [],
|
||||
"metrics": []
|
||||
}
|
40
tests/specs/cli/otel_basic/links.ts
Normal file
40
tests/specs/cli/otel_basic/links.ts
Normal file
|
@ -0,0 +1,40 @@
|
|||
// Copyright 2018-2025 the Deno authors. MIT license.
|
||||
|
||||
import { trace } from "npm:@opentelemetry/api@1.9.0";
|
||||
|
||||
const tracer = trace.getTracer("example-tracer");
|
||||
|
||||
const span1 = tracer.startSpan("example span", {
|
||||
links: [{
|
||||
context: {
|
||||
traceId: "1234567890abcdef1234567890abcdef",
|
||||
spanId: "1234567890abcdef",
|
||||
traceFlags: 1,
|
||||
},
|
||||
}],
|
||||
});
|
||||
span1.end();
|
||||
|
||||
const span2 = tracer.startSpan("example span");
|
||||
span2.addLink({
|
||||
context: {
|
||||
traceId: "1234567890abcdef1234567890abcdef",
|
||||
spanId: "1234567890abcdef",
|
||||
traceFlags: 1,
|
||||
},
|
||||
});
|
||||
span2.end();
|
||||
|
||||
const span3 = tracer.startSpan("example span");
|
||||
span3.addLink({
|
||||
context: {
|
||||
traceId: "1234567890abcdef1234567890abcdef",
|
||||
spanId: "1234567890abcdef",
|
||||
traceFlags: 1,
|
||||
},
|
||||
attributes: {
|
||||
key: "value",
|
||||
},
|
||||
droppedAttributesCount: 1,
|
||||
});
|
||||
span3.end();
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"tempDir": true,
|
||||
"args": "install -g --root ./folder --config deno.json main.ts --name my-cli",
|
||||
"output": "install.out"
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"importMap": "./import_map.json"
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
{
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
Warning "importMap" field in the specified config file we be ignored. Use the --import-map flag instead.
|
||||
✅ Successfully installed my-cli
|
||||
[WILDCARD]
|
|
@ -0,0 +1 @@
|
|||
console.log(1);
|
|
@ -4,7 +4,7 @@ import crypto from "node:crypto";
|
|||
import { Buffer } from "node:buffer";
|
||||
import testVectors128 from "./gcmEncryptExtIV128.json" with { type: "json" };
|
||||
import testVectors256 from "./gcmEncryptExtIV256.json" with { type: "json" };
|
||||
import { assertEquals } from "@std/assert";
|
||||
import { assertEquals, assertThrows } from "@std/assert";
|
||||
|
||||
const aesGcm = (bits: string, key: Uint8Array) => {
|
||||
const ALGO = bits == "128" ? `aes-128-gcm` : `aes-256-gcm`;
|
||||
|
@ -123,7 +123,7 @@ Deno.test({
|
|||
// Issue #27441
|
||||
// https://github.com/denoland/deno/issues/27441
|
||||
Deno.test({
|
||||
name: "aes-256-gcm supports IV of non standard length",
|
||||
name: "aes-256-gcm supports IV of non standard length and auth tag check",
|
||||
fn() {
|
||||
const decipher = crypto.createDecipheriv(
|
||||
"aes-256-gcm",
|
||||
|
@ -136,6 +136,10 @@ Deno.test({
|
|||
"utf-8",
|
||||
);
|
||||
assertEquals(decrypted, "this is a secret");
|
||||
decipher.final();
|
||||
assertThrows(
|
||||
() => decipher.final(),
|
||||
TypeError,
|
||||
"Failed to authenticate data",
|
||||
);
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue